Skip to main content

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