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#![warn(unreachable_pub)]
7
8mod command;
9mod macros;
10mod util;
11
12pub mod artifact_names;
13pub mod assertion_helpers;
14pub mod diff;
15pub mod env;
16pub mod external_deps;
17pub mod linker;
18pub mod path_helpers;
19pub mod run;
20pub mod scoped_run;
21pub mod string;
22pub mod symbols;
23pub mod targets;
24
25// Internally we call our fs-related support module as `fs`, but re-export its content as `rfs`
26// to tests to avoid colliding with commonly used `use std::fs;`.
27mod fs;
28
29/// [`std::fs`] wrappers and assorted filesystem-related helpers. Public to tests as `rfs` to not be
30/// confused with [`std::fs`].
31pub mod rfs {
32    pub use crate::fs::*;
33}
34
35// Re-exports of third-party library crates.
36pub use {bstr, gimli, libc, object, regex, serde_json, similar, wasmparser};
37
38// Helpers for building names of output artifacts that are potentially target-specific.
39pub use crate::artifact_names::{
40    bin_name, dynamic_lib_extension, dynamic_lib_name, msvc_import_dynamic_lib_name, rust_lib_name,
41    static_lib_name,
42};
43pub use crate::assertion_helpers::{
44    assert_contains, assert_contains_regex, assert_count_is, assert_dirs_are_equal, assert_equals,
45    assert_not_contains, assert_not_contains_regex,
46};
47// `diff` is implemented in terms of the [similar] library.
48//
49// [similar]: https://github.com/mitsuhiko/similar
50pub use crate::diff::{Diff, diff};
51// Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers.
52pub use crate::env::{env_var, env_var_os, set_current_dir};
53pub use crate::external_deps::c_build::{
54    build_native_dynamic_lib, build_native_static_lib, build_native_static_lib_cxx,
55    build_native_static_lib_optimized,
56};
57// Re-exports of external dependencies.
58pub use crate::external_deps::c_cxx_compiler::{
59    Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc,
60};
61pub use crate::external_deps::cargo::cargo;
62pub use crate::external_deps::clang::{Clang, clang};
63pub use crate::external_deps::htmldocck::htmldocck;
64pub use crate::external_deps::llvm::{
65    self, LlvmAr, LlvmBcanalyzer, LlvmDis, LlvmDwarfdump, LlvmFilecheck, LlvmNm, LlvmObjcopy,
66    LlvmObjdump, LlvmProfdata, LlvmReadobj, llvm_ar, llvm_bcanalyzer, llvm_dis, llvm_dwarfdump,
67    llvm_filecheck, llvm_nm, llvm_objcopy, llvm_objdump, llvm_profdata, llvm_readobj,
68};
69pub use crate::external_deps::python::python_command;
70pub use crate::external_deps::rustc::{self, Rustc, bare_rustc, rustc, rustc_path};
71pub use crate::external_deps::rustdoc::{Rustdoc, bare_rustdoc, rustdoc};
72// Path-related helpers.
73pub use crate::path_helpers::{
74    build_root, cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix,
75    has_suffix, not_contains, path, shallow_find_directories, shallow_find_files, source_root,
76};
77// Convenience helpers for running binaries and other commands.
78pub use crate::run::{cmd, run, run_fail, run_with_args};
79// Helpers for scoped test execution where certain properties are attempted to be maintained.
80pub use crate::scoped_run::{run_in_tmpdir, test_while_readonly};
81pub use crate::string::{
82    count_regex_matches_in_files_with_extension, invalid_utf8_contains, invalid_utf8_not_contains,
83};
84// Helpers for checking target information.
85pub use crate::targets::{
86    apple_os, is_aix, is_darwin, is_win7, is_windows, is_windows_gnu, is_windows_msvc,
87    llvm_components_contain, target, uname,
88};