Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ pub fn check_library_requirements(db: &DriverDataBase) -> Vec<String> {
missing.extend(
core_requirements::check_core_requirements(db, top_mod.scope(), core.kind(db))
.into_iter()
.map(|req| req.to_string()),
.map(|violation| violation.to_string()),
);
} else {
missing.push("missing required core ingot".to_string());
Expand All @@ -247,7 +247,7 @@ pub fn check_library_requirements(db: &DriverDataBase) -> Vec<String> {
missing.extend(
core_requirements::check_std_type_requirements(db, top_mod.scope(), std_ingot.kind(db))
.into_iter()
.map(|req| req.to_string()),
.map(|violation| violation.to_string()),
);
} else {
missing.push("missing required std ingot".to_string());
Expand Down
31 changes: 25 additions & 6 deletions crates/fe/tests/crash_regressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use std::{
time::{Duration, Instant},
};

const FE_CHECK_TIMEOUT: Duration = Duration::from_secs(5);
const FE_CHECK_TIMEOUT_STANDALONE: Duration = Duration::from_secs(5);
const FE_CHECK_TIMEOUT_PROJECT: Duration = Duration::from_secs(60);

struct FeCheckRun {
code: i32,
Expand All @@ -24,6 +25,10 @@ fn is_fe_file(path: &Path) -> bool {
path.extension().and_then(OsStr::to_str) == Some("fe")
}

fn is_project_fixture(path: &Path) -> bool {
path.is_dir() && path.join("fe.toml").is_file()
}

fn spawn_reader<R: Read + Send + 'static>(mut pipe: R) -> thread::JoinHandle<Vec<u8>> {
thread::spawn(move || {
let mut buf = Vec::new();
Expand All @@ -34,9 +39,22 @@ fn spawn_reader<R: Read + Send + 'static>(mut pipe: R) -> thread::JoinHandle<Vec
})
}

fn fe_check_timeout(path: &Path) -> Duration {
if path.is_file() {
FE_CHECK_TIMEOUT_STANDALONE
} else {
FE_CHECK_TIMEOUT_PROJECT
}
}

fn run_fe_check(path: &Path) -> FeCheckRun {
let mut child = Command::new(env!("CARGO_BIN_EXE_fe"))
.args(["check", "--standalone", "--color", "never"])
let mut command = Command::new(env!("CARGO_BIN_EXE_fe"));
command.arg("check");
if path.is_file() {
command.arg("--standalone");
}
let mut child = command
.args(["--color", "never"])
.arg(path)
.env("NO_COLOR", "1")
.env("RUST_BACKTRACE", "0")
Expand All @@ -60,6 +78,7 @@ fn run_fe_check(path: &Path) -> FeCheckRun {
);

let start = Instant::now();
let timeout = fe_check_timeout(path);
let timed_out = loop {
if child
.try_wait()
Expand All @@ -69,7 +88,7 @@ fn run_fe_check(path: &Path) -> FeCheckRun {
break false;
}

if start.elapsed() >= FE_CHECK_TIMEOUT {
if start.elapsed() >= timeout {
let _ = child.kill();
break true;
}
Expand Down Expand Up @@ -108,7 +127,7 @@ fn crash_regressions_do_not_panic() {
let mut fixtures: Vec<PathBuf> = fs::read_dir(&dir)
.unwrap_or_else(|err| panic!("failed to read crash regressions dir {dir:?}: {err}"))
.filter_map(|entry| entry.ok().map(|e| e.path()))
.filter(|path| is_fe_file(path))
.filter(|path| is_fe_file(path) || is_project_fixture(path))
.collect();
fixtures.sort();

Expand All @@ -125,7 +144,7 @@ fn crash_regressions_do_not_panic() {
assert!(
!run.timed_out,
"`fe check` timed out after {:?} on {fixture:?}\n{combined}",
FE_CHECK_TIMEOUT
fe_check_timeout(&fixture)
);
assert_ne!(code, 101, "`fe check` panicked on {fixture:?}\n{combined}");
assert!(
Expand Down
7 changes: 5 additions & 2 deletions crates/fe/tests/fixtures/crash_regressions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
These fixtures are minimal inputs that previously triggered compiler panics/ICEs or hangs found by
fuzzing.

Top-level `.fe` files are checked in standalone mode. Top-level directories with `fe.toml` are
checked as projects so multi-file repros can stay intact.

Keep each fixture focused on the smallest construct that still reaches the former panic path.

They are used by `crates/fe/tests/crash_regressions.rs` to ensure `fe check --standalone` never
panics or times out on them (it should emit diagnostics and exit normally).
They are used by `crates/fe/tests/crash_regressions.rs` to ensure `fe check` never panics or times
out on them (it should emit diagnostics and exit normally).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ingot]
name = "core"
version = "0.1.0"
Loading
Loading