Skip to content

Commit 00762eb

Browse files
authored
Merge pull request #266 from oli-obk/miri
Make a bunch of things public so that miri can use them
2 parents bd97dc2 + 98c2b73 commit 00762eb

File tree

13 files changed

+59
-36
lines changed

13 files changed

+59
-36
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ui_test"
3-
version = "0.26.0"
3+
version = "0.26.1"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
description = "A test framework for testing rustc diagnostics output"

src/config.rs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ use spanned::Spanned;
44

55
#[cfg(feature = "rustc")]
66
use crate::{
7-
aux_builds::AuxBuilder, build_manager::BuildManager, custom_flags::run::Run,
8-
custom_flags::rustfix::RustfixMode, custom_flags::Flag, filter::Match,
9-
per_test_config::TestConfig, rustc_stderr, Errored,
7+
aux_builds::AuxBuilder, custom_flags::run::Run, custom_flags::rustfix::RustfixMode,
8+
custom_flags::Flag, filter::Match, rustc_stderr,
109
};
1110
use crate::{
1211
diagnostics::Diagnostics,
@@ -75,29 +74,9 @@ impl Config {
7574
/// `rustc` on the test files.
7675
#[cfg(feature = "rustc")]
7776
pub fn rustc(root_dir: impl Into<PathBuf>) -> Self {
78-
let mut comment_defaults = Comments::default();
79-
80-
#[derive(Debug)]
81-
struct Edition(String);
82-
83-
impl Flag for Edition {
84-
fn must_be_unique(&self) -> bool {
85-
true
86-
}
87-
fn clone_inner(&self) -> Box<dyn Flag> {
88-
Box::new(Edition(self.0.clone()))
89-
}
77+
use crate::custom_flags::edition::Edition;
9078

91-
fn apply(
92-
&self,
93-
cmd: &mut std::process::Command,
94-
_config: &TestConfig,
95-
_build_manager: &BuildManager,
96-
) -> Result<(), Errored> {
97-
cmd.arg("--edition").arg(&self.0);
98-
Ok(())
99-
}
100-
}
79+
let mut comment_defaults = Comments::default();
10180

10281
#[derive(Debug)]
10382
struct NeedsAsmSupport;

src/custom_flags.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use std::{
77

88
use crate::{build_manager::BuildManager, per_test_config::TestConfig, Config, Errored};
99

10+
#[cfg(feature = "rustc")]
11+
pub mod edition;
1012
#[cfg(feature = "rustc")]
1113
pub mod run;
1214
pub mod rustfix;

src/custom_flags/edition.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//! Custom flag for setting the edition for all tests
2+
3+
use crate::{build_manager::BuildManager, per_test_config::TestConfig, Errored};
4+
5+
use super::Flag;
6+
7+
#[derive(Debug)]
8+
/// Set the edition of the tests
9+
pub struct Edition(pub String);
10+
11+
impl Flag for Edition {
12+
fn must_be_unique(&self) -> bool {
13+
true
14+
}
15+
fn clone_inner(&self) -> Box<dyn Flag> {
16+
Box::new(Edition(self.0.clone()))
17+
}
18+
19+
fn apply(
20+
&self,
21+
cmd: &mut std::process::Command,
22+
_config: &TestConfig,
23+
_build_manager: &BuildManager,
24+
) -> Result<(), Errored> {
25+
cmd.arg("--edition").arg(&self.0);
26+
Ok(())
27+
}
28+
}

src/per_test_config.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub use crate::diagnostics::Level;
1818
use crate::diagnostics::{Diagnostics, Message};
1919
pub use crate::parser::{Comments, Condition, Revisioned};
2020
use crate::parser::{ErrorMatch, ErrorMatchKind, OptWithLine};
21-
use crate::status_emitter::TestStatus;
21+
use crate::status_emitter::{SilentStatus, TestStatus};
2222
use crate::test_result::{Errored, TestOk, TestResult};
2323
use crate::{core::strip_path_prefix, Config, Error, Errors, OutputConflictHandling};
2424

@@ -34,6 +34,19 @@ pub struct TestConfig {
3434
}
3535

3636
impl TestConfig {
37+
/// Create a config for running one file.
38+
pub fn one_off_runner(config: Config, path: PathBuf) -> Self {
39+
Self {
40+
comments: Arc::new(config.comment_defaults.clone()),
41+
config,
42+
aux_dir: PathBuf::new(),
43+
status: Box::new(SilentStatus {
44+
revision: "".into(),
45+
path,
46+
}),
47+
}
48+
}
49+
3750
pub(crate) fn patch_out_dir(&mut self) {
3851
// Put aux builds into a separate directory per path so that multiple aux files
3952
// from different directories (but with the same file name) don't collide.
@@ -112,7 +125,8 @@ impl TestConfig {
112125
Ok(())
113126
}
114127

115-
pub(crate) fn build_command(&self, build_manager: &BuildManager) -> Result<Command, Errored> {
128+
/// Produce the command that will be executed to run the test.
129+
pub fn build_command(&self, build_manager: &BuildManager) -> Result<Command, Errored> {
116130
let mut cmd = self.config.program.build(&self.config.out_dir);
117131
cmd.arg(self.status.path());
118132
if !self.status.revision().is_empty() {

tests/integrations/basic-bin/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integrations/basic-fail-mode/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integrations/basic-fail/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integrations/basic/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)