Skip to content

Commit ce4699d

Browse files
committed
compiletest: Make all other modules non-public
All APIs used from outside the compiletest library crate have been isolated to the `cli` and `rustdoc_gui_test` modules, so no other items need to be publicly exported.
1 parent b4f64fd commit ce4699d

File tree

6 files changed

+17
-31
lines changed

6 files changed

+17
-31
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,9 +1974,6 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
19741974
} else if mode == "rustdoc-js" {
19751975
panic!("need nodejs to run rustdoc-js suite");
19761976
}
1977-
if let Some(ref npm) = builder.config.npm {
1978-
cmd.arg("--npm").arg(npm);
1979-
}
19801977
if builder.config.rust_optimize_tests {
19811978
cmd.arg("--optimize-tests");
19821979
}

src/tools/compiletest/src/common.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,6 @@ pub struct Config {
631631

632632
/// Path to a NodeJS executable. Used for JS doctests, emscripten and WASM tests.
633633
pub nodejs: Option<String>,
634-
/// Path to a npm executable. Used for rustdoc GUI tests.
635-
pub npm: Option<String>,
636634

637635
/// Whether to rerun tests even if the inputs are unchanged.
638636
pub force_rerun: bool,
@@ -721,7 +719,8 @@ impl Config {
721719
self.target_cfg().abi == abi
722720
}
723721

724-
pub fn matches_family(&self, family: &str) -> bool {
722+
#[cfg_attr(not(test), expect(dead_code, reason = "only used by tests for `ignore-{family}`"))]
723+
pub(crate) fn matches_family(&self, family: &str) -> bool {
725724
self.target_cfg().families.iter().any(|f| f == family)
726725
}
727726

src/tools/compiletest/src/directives.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ pub struct TestProps {
198198
pub filecheck_flags: Vec<String>,
199199
/// Don't automatically insert any `--check-cfg` args
200200
pub no_auto_check_cfg: bool,
201-
/// Run tests which require enzyme being build
202-
pub has_enzyme: bool,
203201
/// Build and use `minicore` as `core` stub for `no_core` tests in cross-compilation scenarios
204202
/// that don't otherwise want/need `-Z build-std`.
205203
pub add_core_stubs: bool,
@@ -314,7 +312,6 @@ impl TestProps {
314312
llvm_cov_flags: vec![],
315313
filecheck_flags: vec![],
316314
no_auto_check_cfg: false,
317-
has_enzyme: false,
318315
add_core_stubs: false,
319316
core_stubs_compile_flags: vec![],
320317
dont_require_annotations: Default::default(),

src/tools/compiletest/src/lib.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
mod tests;
55

66
pub mod cli;
7-
pub mod common;
7+
mod common;
88
mod debuggers;
9-
pub mod diagnostics;
10-
pub mod directives;
11-
pub mod edition;
12-
pub mod errors;
9+
mod diagnostics;
10+
mod directives;
11+
mod edition;
12+
mod errors;
1313
mod executor;
1414
mod json;
1515
mod output_capture;
1616
mod panic_hook;
1717
mod raise_fd_limit;
1818
mod read2;
19-
pub mod runtest;
19+
mod runtest;
2020
pub mod rustdoc_gui_test;
21-
pub mod util;
21+
mod util;
2222

2323
use core::panic;
2424
use std::collections::HashSet;
@@ -50,7 +50,7 @@ use crate::executor::{CollectedTest, ColorConfig};
5050
/// The config mostly reflects command-line arguments, but there might also be
5151
/// some code here that inspects environment variables or even runs executables
5252
/// (e.g. when discovering debugger versions).
53-
pub fn parse_config(args: Vec<String>) -> Config {
53+
fn parse_config(args: Vec<String>) -> Config {
5454
let mut opts = Options::new();
5555
opts.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH")
5656
.reqopt("", "run-lib-path", "path to target shared libraries", "PATH")
@@ -464,7 +464,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
464464
host_linker: matches.opt_str("host-linker"),
465465
llvm_components: matches.opt_str("llvm-components").unwrap(),
466466
nodejs: matches.opt_str("nodejs"),
467-
npm: matches.opt_str("npm"),
468467

469468
force_rerun: matches.opt_present("force-rerun"),
470469

@@ -488,22 +487,15 @@ pub fn parse_config(args: Vec<String>) -> Config {
488487
}
489488
}
490489

491-
pub fn opt_str(maybestr: &Option<String>) -> &str {
492-
match *maybestr {
493-
None => "(none)",
494-
Some(ref s) => s,
495-
}
496-
}
497-
498-
pub fn opt_str2(maybestr: Option<String>) -> String {
490+
fn opt_str2(maybestr: Option<String>) -> String {
499491
match maybestr {
500492
None => "(none)".to_owned(),
501493
Some(s) => s,
502494
}
503495
}
504496

505497
/// Called by `main` after the config has been parsed.
506-
pub fn run_tests(config: Arc<Config>) {
498+
fn run_tests(config: Arc<Config>) {
507499
debug!(?config, "run_tests");
508500

509501
panic_hook::install_panic_hook();
@@ -641,7 +633,7 @@ impl TestCollector {
641633
/// FIXME(Zalathar): Now that we no longer rely on libtest, try to overhaul
642634
/// test discovery to take into account the filters/tests specified on the
643635
/// command-line, instead of having to enumerate everything.
644-
pub(crate) fn collect_and_make_tests(config: Arc<Config>) -> Vec<CollectedTest> {
636+
fn collect_and_make_tests(config: Arc<Config>) -> Vec<CollectedTest> {
645637
debug!("making tests from {}", config.src_test_suite_root);
646638
let common_inputs_stamp = common_inputs_stamp(&config);
647639
let modified_tests =
@@ -853,7 +845,7 @@ fn collect_tests_from_dir(
853845
}
854846

855847
/// Returns true if `file_name` looks like a proper test file name.
856-
pub fn is_test(file_name: &str) -> bool {
848+
fn is_test(file_name: &str) -> bool {
857849
if !file_name.ends_with(".rs") {
858850
return false;
859851
}
@@ -1133,7 +1125,7 @@ fn check_for_overlapping_test_paths(found_path_stems: &HashSet<Utf8PathBuf>) {
11331125
}
11341126
}
11351127

1136-
pub fn early_config_check(config: &Config) {
1128+
fn early_config_check(config: &Config) {
11371129
if !config.has_html_tidy && config.mode == TestMode::Rustdoc {
11381130
warning!("`tidy` (html-tidy.org) is not installed; diffs will not be generated");
11391131
}

src/tools/compiletest/src/rustdoc_gui_test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ fn incomplete_config_for_rustdoc_gui_test() -> Config {
125125
host_linker: Default::default(),
126126
llvm_components: Default::default(),
127127
nodejs: Default::default(),
128-
npm: Default::default(),
129128
force_rerun: Default::default(),
130129
only_modified: Default::default(),
131130
target_cfgs: Default::default(),

src/tools/compiletest/src/util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ macro_rules! string_enum {
102102
}
103103

104104
impl $name {
105+
#[allow(dead_code)]
105106
$vis const VARIANTS: &'static [Self] = &[$(Self::$variant,)*];
107+
#[allow(dead_code)]
106108
$vis const STR_VARIANTS: &'static [&'static str] = &[$(Self::$variant.to_str(),)*];
107109

108110
$vis const fn to_str(&self) -> &'static str {

0 commit comments

Comments
 (0)