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;
43// FIXME(#137532): replace with std `anonymous_pipe` once it stabilizes and reaches beta.
44pub use os_pipe;
45pub use regex;
46pub use serde_json;
47pub use similar;
48pub use wasmparser;
49// tidy-alphabetical-end
50
51// Re-exports of external dependencies.
52pub use external_deps::{
53    cargo, c_build, c_cxx_compiler, clang, htmldocck, llvm, python, rustc, rustdoc
54};
55
56// These rely on external dependencies.
57pub use c_cxx_compiler::{Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc};
58pub use c_build::{
59    build_native_dynamic_lib, build_native_static_lib, build_native_static_lib_cxx,
60    build_native_static_lib_optimized,
61};
62pub use cargo::cargo;
63pub use clang::{clang, Clang};
64pub use htmldocck::htmldocck;
65pub use llvm::{
66    llvm_ar, llvm_bcanalyzer, llvm_dis, llvm_dwarfdump, llvm_filecheck, llvm_nm, llvm_objcopy,
67    llvm_objdump, llvm_profdata, llvm_readobj, LlvmAr, LlvmBcanalyzer, LlvmDis, LlvmDwarfdump,
68    LlvmFilecheck, LlvmNm, LlvmObjcopy, LlvmObjdump, LlvmProfdata, LlvmReadobj,
69};
70pub use python::python_command;
71pub use rustc::{aux_build, bare_rustc, rustc, rustc_path, Rustc};
72pub use rustdoc::{rustdoc, Rustdoc};
73
74/// [`diff`][mod@diff] is implemented in terms of the [similar] library.
75///
76/// [similar]: https://github.com/mitsuhiko/similar
77pub use diff::{diff, Diff};
78
79/// Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers.
80pub use env::{env_var, env_var_os, set_current_dir};
81
82/// Convenience helpers for running binaries and other commands.
83pub use run::{cmd, run, run_fail, run_with_args};
84
85/// Helpers for checking target information.
86pub use targets::{
87    apple_os, is_aix, is_darwin, is_msvc, is_windows, is_windows_gnu, is_win7, llvm_components_contain,
88    target, uname,
89};
90
91/// Helpers for building names of output artifacts that are potentially target-specific.
92pub use artifact_names::{
93    bin_name, dynamic_lib_extension, dynamic_lib_name, msvc_import_dynamic_lib_name, rust_lib_name,
94    static_lib_name,
95};
96
97/// Path-related helpers.
98pub use path_helpers::{
99    build_root, cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix,
100    has_suffix, not_contains, path, shallow_find_directories, shallow_find_files, source_root,
101};
102
103/// Helpers for scoped test execution where certain properties are attempted to be maintained.
104pub use scoped_run::{run_in_tmpdir, test_while_readonly};
105
106pub use assertion_helpers::{
107    assert_contains, assert_contains_regex, assert_count_is, assert_dirs_are_equal, assert_equals,
108    assert_not_contains, assert_not_contains_regex,
109};
110
111pub use string::{
112    count_regex_matches_in_files_with_extension, invalid_utf8_contains, invalid_utf8_not_contains,
113};