Skip to content

Commit

Permalink
Cleanup writing test-checker output.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbuchan committed Nov 14, 2023
1 parent 25e748d commit 767e1a1
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions xtask/src/type_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,27 @@ fn test_conformance() -> anyhow::Result<()> {
// This is more complicated than using .output(), but there's a *lot* of
// output we throw out, so this is much better for memory. You could also use it
// for reporting progress, I guess?
let mut tests = Vec::new();
let mut passed_test_lines = Vec::new();
let stdout = child.stdout.take().unwrap();
std::thread::scope({
// Avoid moving the Vec into the thread
let tests = &mut tests;
let passed_test_lines = &mut passed_test_lines;
move |scope| {
scope.spawn(move || {
use std::io::BufRead;
let stdout = std::io::BufReader::new(stdout);
for line in stdout.lines() {
let line = line.unwrap();
let mut line = line.unwrap();
// fixme: there are some .tsx files...?
if line.ends_with(".ts ... ok") {
tests.push(
line.replace("test conformance::", "")
.replace(" ... ok", "")
.replace("::", "/")
.replace("test ", "")
.replace('\\', "/"),
);
line = line
.replace("test conformance::", "")
.replace(" ... ok", "")
.replace("::", "/")
.replace("test ", "")
.replace('\\', "/");
line.push('\n');
passed_test_lines.push(line);
}
}
});
Expand All @@ -72,14 +73,8 @@ fn test_conformance() -> anyhow::Result<()> {
let status = child.wait()?;
ensure!(status.success(), "test conformance failed: {status}");

tests.sort();

use std::io::Write;
let mut file = std::fs::File::create("crates/stc_ts_type_checker/tests/conformance.pass.txt")?;
for line in &tests {
writeln!(file, "{line}").unwrap();
}
drop(file);
passed_test_lines.sort();
std::fs::write("crates/stc_ts_type_checker/tests/conformance.pass.txt", passed_test_lines.concat())?;

Ok(())
}

0 comments on commit 767e1a1

Please sign in to comment.