Skip to content

Commit 5a65712

Browse files
committed
Support running miri test in the orchestrator
1 parent ac81765 commit 5a65712

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
@@ -668,6 +668,7 @@ pub struct MiriRequest {
668668
pub channel: Channel,
669669
pub crate_type: CrateType,
670670
pub edition: Edition,
671+
pub tests: bool,
671672
pub aliasing_model: AliasingModel,
672673
pub code: String,
673674
}
@@ -692,9 +693,11 @@ impl LowerRequest for MiriRequest {
692693

693694
let miriflags = miriflags.join(" ");
694695

696+
let subcommand = if self.tests { "test" } else { "run" };
697+
695698
ExecuteCommandRequest {
696699
cmd: "cargo".to_owned(),
697-
args: ["miri", "run"].map(Into::into).into(),
700+
args: ["miri", subcommand].map(Into::into).into(),
698701
envs: kvs! {
699702
"MIRIFLAGS" => miriflags,
700703
// Be sure that `cargo miri` will not build a new
@@ -3975,6 +3978,7 @@ mod tests {
39753978
channel: Channel::Nightly,
39763979
crate_type: CrateType::Binary,
39773980
edition: Edition::Rust2021,
3981+
tests: false,
39783982
aliasing_model: AliasingModel::Stacked,
39793983
code: String::new(),
39803984
};
@@ -4007,6 +4011,36 @@ mod tests {
40074011
Ok(())
40084012
}
40094013

4014+
#[tokio::test]
4015+
#[snafu::report]
4016+
async fn miri_tests() -> Result<()> {
4017+
let coordinator = new_coordinator();
4018+
4019+
let req = MiriRequest {
4020+
tests: true,
4021+
code: r#"
4022+
#[test]
4023+
fn oops() {
4024+
unsafe { core::mem::MaybeUninit::<u8>::uninit().assume_init() };
4025+
}
4026+
"#
4027+
.into(),
4028+
..ARBITRARY_MIRI_REQUEST
4029+
};
4030+
4031+
let response = coordinator.miri(req).with_timeout().await.unwrap();
4032+
4033+
assert!(!response.success, "stderr: {}", response.stderr);
4034+
4035+
assert_contains!(response.stderr, "Undefined Behavior");
4036+
assert_contains!(response.stderr, "using uninitialized data");
4037+
assert_contains!(response.stderr, "operation requires initialized memory");
4038+
4039+
coordinator.shutdown().await?;
4040+
4041+
Ok(())
4042+
}
4043+
40104044
const ARBITRARY_MACRO_EXPANSION_REQUEST: MacroExpansionRequest = MacroExpansionRequest {
40114045
channel: Channel::Nightly,
40124046
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)