Skip to content

Commit 15fdf1d

Browse files
committed
compiletest: make some internals pub for use as a library
Make Config, TestPaths, CollectedTest, CollectedTestDesc, ShouldFail, FileDirectives, parse_config and collect_and_make_tests public so that external tools can depend on compiletest as a library and use its test collection infrastructure directly. r? jackh726
1 parent bfc05d6 commit 15fdf1d

4 files changed

Lines changed: 24 additions & 24 deletions

File tree

src/tools/compiletest/src/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ pub(crate) fn query_rustc_output(
11691169

11701170
/// Path information for a single test file.
11711171
#[derive(Debug, Clone)]
1172-
pub(crate) struct TestPaths {
1172+
pub struct TestPaths {
11731173
/// Full path to the test file.
11741174
///
11751175
/// For example:
@@ -1182,7 +1182,7 @@ pub(crate) struct TestPaths {
11821182
///
11831183
/// For example:
11841184
/// - `/home/ferris/rust/tests/run-make/emit`
1185-
pub(crate) file: Utf8PathBuf,
1185+
pub file: Utf8PathBuf,
11861186

11871187
/// Subset of the full path that excludes the suite directory and the
11881188
/// test filename. For tests in the root of their test suite directory,
@@ -1191,7 +1191,7 @@ pub(crate) struct TestPaths {
11911191
/// For example:
11921192
/// - `file`: `/home/ferris/rust/tests/ui/warnings/hello-world.rs`
11931193
/// - `relative_dir`: `warnings`
1194-
pub(crate) relative_dir: Utf8PathBuf,
1194+
pub relative_dir: Utf8PathBuf,
11951195
}
11961196

11971197
/// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`.

src/tools/compiletest/src/directives/file.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ use camino::Utf8Path;
33
use crate::directives::LineNumber;
44
use crate::directives::line::{DirectiveLine, line_directive};
55

6-
pub(crate) struct FileDirectives<'a> {
7-
pub(crate) path: &'a Utf8Path,
8-
pub(crate) lines: Vec<DirectiveLine<'a>>,
6+
pub struct FileDirectives<'a> {
7+
pub path: &'a Utf8Path,
8+
pub lines: Vec<DirectiveLine<'a>>,
99

1010
/// Whether the test source file contains an explicit `#![no_std]`/`#![no_core]` attribute.
11-
pub(crate) has_explicit_no_std_core_attribute: bool,
11+
pub has_explicit_no_std_core_attribute: bool,
1212
}
1313

1414
impl<'a> FileDirectives<'a> {
15-
pub(crate) fn from_file_contents(path: &'a Utf8Path, file_contents: &'a str) -> Self {
15+
pub fn from_file_contents(path: &'a Utf8Path, file_contents: &'a str) -> Self {
1616
let mut lines = vec![];
1717
let mut has_explicit_no_std_core_attribute = false;
1818

src/tools/compiletest/src/executor.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -325,26 +325,26 @@ fn get_concurrency() -> usize {
325325
}
326326

327327
/// Information that was historically needed to create a libtest `TestDescAndFn`.
328-
pub(crate) struct CollectedTest {
329-
pub(crate) desc: CollectedTestDesc,
330-
pub(crate) config: Arc<Config>,
331-
pub(crate) testpaths: TestPaths,
332-
pub(crate) revision: Option<String>,
328+
pub struct CollectedTest {
329+
pub desc: CollectedTestDesc,
330+
pub config: Arc<Config>,
331+
pub testpaths: TestPaths,
332+
pub revision: Option<String>,
333333
}
334334

335335
/// Information that was historically needed to create a libtest `TestDesc`.
336-
pub(crate) struct CollectedTestDesc {
337-
pub(crate) name: String,
338-
pub(crate) filterable_path: Utf8PathBuf,
339-
pub(crate) ignore: bool,
340-
pub(crate) ignore_message: Option<Cow<'static, str>>,
341-
pub(crate) should_fail: ShouldFail,
336+
pub struct CollectedTestDesc {
337+
pub name: String,
338+
pub filterable_path: Utf8PathBuf,
339+
pub ignore: bool,
340+
pub ignore_message: Option<Cow<'static, str>>,
341+
pub should_fail: ShouldFail,
342342
}
343343

344344
/// Tests with `//@ should-fail` are tests of compiletest itself, and should
345345
/// be reported as successful if and only if they would have _failed_.
346346
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
347-
pub(crate) enum ShouldFail {
347+
pub enum ShouldFail {
348348
No,
349349
Yes,
350350
}

src/tools/compiletest/src/lib.rs

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

66
pub mod cli;
7-
mod common;
7+
pub mod common;
88
mod debuggers;
99
mod diagnostics;
10-
mod directives;
10+
pub mod directives;
1111
mod edition;
1212
mod errors;
1313
mod executor;
@@ -49,7 +49,7 @@ use crate::executor::CollectedTest;
4949
/// The config mostly reflects command-line arguments, but there might also be
5050
/// some code here that inspects environment variables or even runs executables
5151
/// (e.g. when discovering debugger versions).
52-
fn parse_config(args: Vec<String>) -> Config {
52+
pub fn parse_config(args: Vec<String>) -> Config {
5353
let mut opts = Options::new();
5454
opts.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH")
5555
.reqopt("", "run-lib-path", "path to target shared libraries", "PATH")
@@ -650,7 +650,7 @@ impl TestCollector {
650650
/// FIXME(Zalathar): Now that we no longer rely on libtest, try to overhaul
651651
/// test discovery to take into account the filters/tests specified on the
652652
/// command-line, instead of having to enumerate everything.
653-
fn collect_and_make_tests(config: Arc<Config>) -> Vec<CollectedTest> {
653+
pub fn collect_and_make_tests(config: Arc<Config>) -> Vec<CollectedTest> {
654654
debug!("making tests from {}", config.src_test_suite_root);
655655
let common_inputs_stamp = common_inputs_stamp(&config);
656656
let modified_tests =

0 commit comments

Comments
 (0)