forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#118708 - davidtwco:target-tier-assembly-tes…
…t, r=Mark-Simulacrum tests: add sanity-check assembly test for every target Adds a basic assembly test checking that each target can produce assembly and update the target tier policy to require this. cc rust-lang/compiler-team#655 r? ``@wesleywiser``
- Loading branch information
Showing
5 changed files
with
755 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//! Tests for target tier policy compliance. | ||
//! | ||
//! As of writing, only checks that sanity-check assembly test for targets doesn't miss any targets. | ||
use crate::walk::{filter_not_rust, walk}; | ||
use std::{collections::HashSet, path::Path}; | ||
|
||
const TARGET_DEFINITIONS_PATH: &str = "compiler/rustc_target/src/spec/targets/"; | ||
const ASSEMBLY_TEST_PATH: &str = "tests/assembly/targets.rs"; | ||
const REVISION_LINE_START: &str = "// revisions: "; | ||
|
||
pub fn check(root_path: &Path, bad: &mut bool) { | ||
let mut targets_to_find = HashSet::new(); | ||
|
||
let definitions_path = root_path.join(TARGET_DEFINITIONS_PATH); | ||
for defn in ignore::WalkBuilder::new(&definitions_path) | ||
.max_depth(Some(1)) | ||
.filter_entry(|e| !filter_not_rust(e.path())) | ||
.build() | ||
{ | ||
let defn = defn.unwrap(); | ||
// Skip directory itself. | ||
if defn.path() == definitions_path { | ||
continue; | ||
} | ||
|
||
let path = defn.path(); | ||
let target_name = path.file_stem().unwrap().to_string_lossy().into_owned(); | ||
let _ = targets_to_find.insert(target_name); | ||
} | ||
|
||
walk(&root_path.join(ASSEMBLY_TEST_PATH), |_, _| false, &mut |_, contents| { | ||
for line in contents.lines() { | ||
let Some(_) = line.find(REVISION_LINE_START) else { | ||
continue; | ||
}; | ||
let (_, target_name) = line.split_at(REVISION_LINE_START.len()); | ||
targets_to_find.remove(target_name); | ||
} | ||
}); | ||
|
||
for target in targets_to_find { | ||
tidy_error!(bad, "{ASSEMBLY_TEST_PATH}: missing assembly test for {target}") | ||
} | ||
} |
Oops, something went wrong.