Skip to content

Commit

Permalink
Merge pull request #266 from oli-obk/miri
Browse files Browse the repository at this point in the history
Make a bunch of things public so that miri can use them
  • Loading branch information
oli-obk authored Sep 7, 2024
2 parents bd97dc2 + 98c2b73 commit 00762eb
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ui_test"
version = "0.26.0"
version = "0.26.1"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "A test framework for testing rustc diagnostics output"
Expand Down
29 changes: 4 additions & 25 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use spanned::Spanned;

#[cfg(feature = "rustc")]
use crate::{
aux_builds::AuxBuilder, build_manager::BuildManager, custom_flags::run::Run,
custom_flags::rustfix::RustfixMode, custom_flags::Flag, filter::Match,
per_test_config::TestConfig, rustc_stderr, Errored,
aux_builds::AuxBuilder, custom_flags::run::Run, custom_flags::rustfix::RustfixMode,
custom_flags::Flag, filter::Match, rustc_stderr,
};
use crate::{
diagnostics::Diagnostics,
Expand Down Expand Up @@ -75,29 +74,9 @@ impl Config {
/// `rustc` on the test files.
#[cfg(feature = "rustc")]
pub fn rustc(root_dir: impl Into<PathBuf>) -> Self {
let mut comment_defaults = Comments::default();

#[derive(Debug)]
struct Edition(String);

impl Flag for Edition {
fn must_be_unique(&self) -> bool {
true
}
fn clone_inner(&self) -> Box<dyn Flag> {
Box::new(Edition(self.0.clone()))
}
use crate::custom_flags::edition::Edition;

fn apply(
&self,
cmd: &mut std::process::Command,
_config: &TestConfig,
_build_manager: &BuildManager,
) -> Result<(), Errored> {
cmd.arg("--edition").arg(&self.0);
Ok(())
}
}
let mut comment_defaults = Comments::default();

#[derive(Debug)]
struct NeedsAsmSupport;
Expand Down
2 changes: 2 additions & 0 deletions src/custom_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use std::{

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

#[cfg(feature = "rustc")]
pub mod edition;
#[cfg(feature = "rustc")]
pub mod run;
pub mod rustfix;
Expand Down
28 changes: 28 additions & 0 deletions src/custom_flags/edition.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Custom flag for setting the edition for all tests

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

use super::Flag;

#[derive(Debug)]
/// Set the edition of the tests
pub struct Edition(pub String);

impl Flag for Edition {
fn must_be_unique(&self) -> bool {
true
}
fn clone_inner(&self) -> Box<dyn Flag> {
Box::new(Edition(self.0.clone()))
}

fn apply(
&self,
cmd: &mut std::process::Command,
_config: &TestConfig,
_build_manager: &BuildManager,
) -> Result<(), Errored> {
cmd.arg("--edition").arg(&self.0);
Ok(())
}
}
18 changes: 16 additions & 2 deletions src/per_test_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub use crate::diagnostics::Level;
use crate::diagnostics::{Diagnostics, Message};
pub use crate::parser::{Comments, Condition, Revisioned};
use crate::parser::{ErrorMatch, ErrorMatchKind, OptWithLine};
use crate::status_emitter::TestStatus;
use crate::status_emitter::{SilentStatus, TestStatus};
use crate::test_result::{Errored, TestOk, TestResult};
use crate::{core::strip_path_prefix, Config, Error, Errors, OutputConflictHandling};

Expand All @@ -34,6 +34,19 @@ pub struct TestConfig {
}

impl TestConfig {
/// Create a config for running one file.
pub fn one_off_runner(config: Config, path: PathBuf) -> Self {
Self {
comments: Arc::new(config.comment_defaults.clone()),
config,
aux_dir: PathBuf::new(),
status: Box::new(SilentStatus {
revision: "".into(),
path,
}),
}
}

pub(crate) fn patch_out_dir(&mut self) {
// Put aux builds into a separate directory per path so that multiple aux files
// from different directories (but with the same file name) don't collide.
Expand Down Expand Up @@ -112,7 +125,8 @@ impl TestConfig {
Ok(())
}

pub(crate) fn build_command(&self, build_manager: &BuildManager) -> Result<Command, Errored> {
/// Produce the command that will be executed to run the test.
pub fn build_command(&self, build_manager: &BuildManager) -> Result<Command, Errored> {
let mut cmd = self.config.program.build(&self.config.out_dir);
cmd.arg(self.status.path());
if !self.status.revision().is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/basic-bin/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/integrations/basic-fail-mode/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/integrations/basic-fail/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/integrations/basic/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/integrations/cargo-run/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/integrations/dep-fail/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/integrations/ui_test_dep_bug/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 00762eb

Please sign in to comment.