Skip to content

Commit

Permalink
Adjust test driver due to breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
celinval authored and oli-obk committed Oct 27, 2023
1 parent fd9ce75 commit 16849ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions tools/test-drive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

mod sanity_checks;

extern crate rustc_driver;
extern crate rustc_interface;
extern crate rustc_middle;
extern crate rustc_smir;
extern crate stable_mir;

use rustc_middle::ty::TyCtxt;
use rustc_smir::rustc_internal;
use rustc_smir::{run, rustc_internal};
use stable_mir::CompilerError;
use std::ops::ControlFlow;
use std::panic::{catch_unwind, AssertUnwindSafe};
Expand Down Expand Up @@ -39,7 +41,7 @@ type TestResult = Result<(), String>;
fn main() -> ExitCode {
let args = std::env::args();
let (smir_args, rustc_args): (Vec<String>, _) = args.partition(|arg| arg.starts_with("--smir"));
let callback = if smir_args.contains(&CHECK_ARG.to_string()) {
let result = if smir_args.contains(&CHECK_ARG.to_string()) {
VERBOSE.store(
smir_args.contains(&VERBOSE_ARG.to_string()),
Ordering::Relaxed,
Expand All @@ -48,11 +50,10 @@ fn main() -> ExitCode {
smir_args.contains(&FIXME_ARG.to_string()),
Ordering::Relaxed,
);
test_stable_mir
run!(rustc_args, tcx, test_stable_mir(tcx))
} else {
|_: TyCtxt| ControlFlow::<()>::Continue(())
run!(rustc_args, ControlFlow::<()>::Continue(()))
};
let result = rustc_internal::StableMir::new(rustc_args, callback).run();
if result.is_ok() || matches!(result, Err(CompilerError::Skipped)) {
ExitCode::SUCCESS
} else {
Expand Down
6 changes: 3 additions & 3 deletions tools/test-drive/src/sanity_checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ pub fn test_crates() -> TestResult {

/// Visit all local types, statements and terminator to ensure nothing crashes.
fn check_body(body: stable_mir::mir::Body) {
for bb in body.blocks {
for stable_mir::mir::Statement { kind, .. } in bb.statements {
for bb in &body.blocks {
for stable_mir::mir::Statement { kind, .. } in &bb.statements {
black_box(matches!(kind, stable_mir::mir::StatementKind::Assign(..)));
}
black_box(matches!(
Expand All @@ -108,7 +108,7 @@ fn check_body(body: stable_mir::mir::Body) {
));
}

for local in body.locals {
for local in body.locals() {
black_box(matches!(local.ty.kind(), stable_mir::ty::TyKind::Alias(..)));
}
}

0 comments on commit 16849ae

Please sign in to comment.