Skip to content

Commit 248a5ac

Browse files
committed
Support running miri test in the orchestrator
1 parent 29bc4bd commit 248a5ac

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

compiler/base/orchestrator/src/coordinator.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ pub struct MiriRequest {
660660
pub channel: Channel,
661661
pub crate_type: CrateType,
662662
pub edition: Edition,
663+
pub tests: bool,
663664
pub aliasing_model: AliasingModel,
664665
pub code: String,
665666
}
@@ -684,9 +685,11 @@ impl LowerRequest for MiriRequest {
684685

685686
let miriflags = miriflags.join(" ");
686687

688+
let subcommand = if self.tests { "test" } else { "run" };
689+
687690
ExecuteCommandRequest {
688691
cmd: "cargo".to_owned(),
689-
args: ["miri", "run"].map(Into::into).into(),
692+
args: ["miri", subcommand].map(Into::into).into(),
690693
envs: HashMap::from_iter([
691694
("MIRIFLAGS".to_owned(), miriflags),
692695
// Be sure that `cargo miri` will not build a new
@@ -3966,6 +3969,7 @@ mod tests {
39663969
channel: Channel::Nightly,
39673970
crate_type: CrateType::Binary,
39683971
edition: Edition::Rust2021,
3972+
tests: false,
39693973
aliasing_model: AliasingModel::Stacked,
39703974
code: String::new(),
39713975
};
@@ -3998,6 +4002,36 @@ mod tests {
39984002
Ok(())
39994003
}
40004004

4005+
#[tokio::test]
4006+
#[snafu::report]
4007+
async fn miri_tests() -> Result<()> {
4008+
let coordinator = new_coordinator();
4009+
4010+
let req = MiriRequest {
4011+
tests: true,
4012+
code: r#"
4013+
#[test]
4014+
fn oops() {
4015+
unsafe { core::mem::MaybeUninit::<u8>::uninit().assume_init() };
4016+
}
4017+
"#
4018+
.into(),
4019+
..ARBITRARY_MIRI_REQUEST
4020+
};
4021+
4022+
let response = coordinator.miri(req).with_timeout().await.unwrap();
4023+
4024+
assert!(!response.success, "stderr: {}", response.stderr);
4025+
4026+
assert_contains!(response.stderr, "Undefined Behavior");
4027+
assert_contains!(response.stderr, "using uninitialized data");
4028+
assert_contains!(response.stderr, "operation requires initialized memory");
4029+
4030+
coordinator.shutdown().await?;
4031+
4032+
Ok(())
4033+
}
4034+
40014035
const ARBITRARY_MACRO_EXPANSION_REQUEST: MacroExpansionRequest = MacroExpansionRequest {
40024036
channel: Channel::Nightly,
40034037
crate_type: CrateType::Library(LibraryType::Cdylib),

ui/src/metrics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ impl HasLabelsCore for coordinator::MiriRequest {
361361
channel,
362362
crate_type,
363363
edition,
364+
tests,
364365
aliasing_model: _,
365366
code: _,
366367
} = *self;
@@ -371,7 +372,7 @@ impl HasLabelsCore for coordinator::MiriRequest {
371372
mode: None,
372373
edition: Some(Some(edition)),
373374
crate_type: Some(crate_type),
374-
tests: None,
375+
tests: Some(tests),
375376
backtrace: None,
376377
}
377378
}

ui/src/server_axum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,7 @@ pub(crate) mod api_orchestrator_integration_impls {
13001300
channel: Channel::Nightly, // TODO: use what user has submitted
13011301
crate_type: CrateType::Binary, // TODO: use what user has submitted
13021302
edition: parse_edition(&edition)?,
1303+
tests: false,
13031304
aliasing_model,
13041305
code,
13051306
})

0 commit comments

Comments
 (0)