run_make_support/
lib.rs

1//! `run-make-support` is a support library for run-make tests. It provides command wrappers and
2//! convenience utility functions to help test writers reduce duplication. The support library
3//! notably is built via cargo: this means that if your test wants some non-trivial utility, such
4//! as `object` or `wasmparser`, they can be re-exported and be made available through this library.
5
6// We want to control use declaration ordering and spacing (and preserve use group comments), so
7// skip rustfmt on this file.
8#![cfg_attr(rustfmt, rustfmt::skip)]
9#![warn(unreachable_pub)]
10
11mod command;
12mod macros;
13mod util;
14
15pub mod artifact_names;
16pub mod assertion_helpers;
17pub mod diff;
18pub mod env;
19pub mod external_deps;
20pub mod path_helpers;
21pub mod run;
22pub mod scoped_run;
23pub mod string;
24pub mod targets;
25pub mod symbols;
26
27// Internally we call our fs-related support module as `fs`, but re-export its content as `rfs`
28// to tests to avoid colliding with commonly used `use std::fs;`.
29mod fs;
30
31/// [`std::fs`] wrappers and assorted filesystem-related helpers. Public to tests as `rfs` to not be
32/// confused with [`std::fs`].
33pub mod rfs {
34    pub use crate::fs::*;
35}
36
37// Re-exports of third-party library crates.
38// tidy-alphabetical-start
39pub use bstr;
40pub use gimli;
41pub use libc;
42pub use object;
43pub use regex;
44pub use serde_json;
45pub use similar;
46pub use wasmparser;
47// tidy-alphabetical-end
48
49// Re-exports of external dependencies.
50pub use external_deps::{
51    cargo, c_build, c_cxx_compiler, clang, htmldocck, llvm, python, rustc, rustdoc
52};
53
54// These rely on external dependencies.
55pub use c_cxx_compiler::{Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc};
56pub use c_build::{
57    build_native_dynamic_lib, build_native_static_lib, build_native_static_lib_cxx,
58    build_native_static_lib_optimized,
59};
60pub use cargo::cargo;
61pub use clang::{clang, Clang};
62pub use htmldocck::htmldocck;
63pub use llvm::{
64    llvm_ar, llvm_bcanalyzer, llvm_dis, llvm_dwarfdump, llvm_filecheck, llvm_nm, llvm_objcopy,
65    llvm_objdump, llvm_profdata, llvm_readobj, LlvmAr, LlvmBcanalyzer, LlvmDis, LlvmDwarfdump,
66    LlvmFilecheck, LlvmNm, LlvmObjcopy, LlvmObjdump, LlvmProfdata, LlvmReadobj,
67};
68pub use python::python_command;
69pub use rustc::{aux_build, bare_rustc, rustc, rustc_path, Rustc};
70pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
71
72/// [`diff`][mod@diff] is implemented in terms of the [similar] library.
73///
74/// [similar]: https://github.com/mitsuhiko/similar
75pub use diff::{diff, Diff};
76
77/// Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers.
78pub use env::{env_var, env_var_os, set_current_dir};
79
80/// Convenience helpers for running binaries and other commands.
81pub use run::{cmd, run, run_fail, run_with_args};
82
83/// Helpers for checking target information.
84pub use targets::{
85    apple_os, is_aix, is_darwin, is_msvc, is_windows, is_windows_gnu, llvm_components_contain,
86    target, uname,
87};
88
89/// Helpers for building names of output artifacts that are potentially target-specific.
90pub use artifact_names::{
91    bin_name, dynamic_lib_extension, dynamic_lib_name, msvc_import_dynamic_lib_name, rust_lib_name,
92    static_lib_name,
93};
94
95/// Path-related helpers.
96pub use path_helpers::{
97    build_root, cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix,
98    has_suffix, not_contains, path, shallow_find_directories, shallow_find_files, source_root,
99};
100
101/// Helpers for scoped test execution where certain properties are attempted to be maintained.
102pub use scoped_run::{run_in_tmpdir, test_while_readonly};
103
104pub use assertion_helpers::{
105    assert_contains, assert_contains_regex, assert_count_is, assert_dirs_are_equal, assert_equals,
106    assert_not_contains, assert_not_contains_regex,
107};
108
109pub use string::{
110    count_regex_matches_in_files_with_extension, invalid_utf8_contains, invalid_utf8_not_contains,
111};