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