Skip to content
Merged
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
36 changes: 29 additions & 7 deletions src/v1/stage0/src/bin/bootstrap_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,17 @@ fn floor_smoke() {
"stage0 Cargo.toml missing under {}",
ws.display()
);
assert!(ws.join("dag").is_dir(), "dag/ missing under {}", ws.display());
assert!(
ws.join("dag").is_dir(),
"dag/ missing under {}",
ws.display()
);
let [v1_root, dag_root] = source_roots();
assert!(v1_root.is_dir(), "v1 source root missing: {}", v1_root.display());
assert!(
v1_root.is_dir(),
"v1 source root missing: {}",
v1_root.display()
);
assert!(
dag_root.is_dir(),
"dag source root missing: {}",
Expand Down Expand Up @@ -1204,8 +1212,14 @@ fn floor_suite() -> Vec<WitnessCase> {
fn expensive_suite() -> Vec<WitnessCase> {
vec![
("stage0_cargo_check", stage0_cargo_check),
("strict_compile_diagnostic_count", strict_compile_diagnostic_count),
("stage0_compile_accepts_dag_target", stage0_compile_accepts_dag_target),
(
"strict_compile_diagnostic_count",
strict_compile_diagnostic_count,
),
(
"stage0_compile_accepts_dag_target",
stage0_compile_accepts_dag_target,
),
(
"stage0_compile_imports_ephemeral_generated_source_root",
stage0_compile_imports_ephemeral_generated_source_root,
Expand Down Expand Up @@ -1245,9 +1259,13 @@ fn run_suite(tests: &[WitnessCase]) -> ExitCode {
}

fn main() -> ExitCode {
let suite = std::env::args().nth(1).unwrap_or_else(|| "--suite".to_string());
let suite = std::env::args()
.nth(1)
.unwrap_or_else(|| "--suite".to_string());
let suite_name = if suite == "--suite" {
std::env::args().nth(2).unwrap_or_else(|| "floor".to_string())
std::env::args()
.nth(2)
.unwrap_or_else(|| "floor".to_string())
} else {
suite
};
Expand All @@ -1258,7 +1276,11 @@ fn main() -> ExitCode {
"ci" => ci_suite(),
"l4" => vec![("bootstrap_l4_structural", bootstrap_l4_structural)],
"all" => all_suite(),
other => return fail(format!("unknown suite {other:?}; expected floor|expensive|ci|l4|all")),
other => {
return fail(format!(
"unknown suite {other:?}; expected floor|expensive|ci|l4|all"
))
}
};

run_suite(&tests)
Expand Down
38 changes: 27 additions & 11 deletions src/v1/stage0/src/bin/diagnostics_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ fn diagnostic_messages(result: &PipelineResult) -> Vec<String> {
}

fn has_arity_mismatch(result: &PipelineResult) -> bool {
result.diagnostics.iter().any(|d| {
matches!(&*d.diagnostic, CompilerDiagnostic::ArityMismatch { .. })
})
result
.diagnostics
.iter()
.any(|d| matches!(&*d.diagnostic, CompilerDiagnostic::ArityMismatch { .. }))
}

fn first_arity_mismatch_message(result: &PipelineResult) -> Option<String> {
Expand All @@ -192,17 +193,32 @@ fn import_resolution_variants_and_span(module_index: &ModuleIndex) {
assert_eq!(missing_result.diagnostics.len(), 1);
let missing = &missing_result.diagnostics[0];
assert!(
matches!(&*missing.diagnostic, CompilerDiagnostic::MissingExport { .. }),
matches!(
&*missing.diagnostic,
CompilerDiagnostic::MissingExport { .. }
),
"expected MissingExport, got: {:?}",
missing.diagnostic
);
let missing_msg = diagnostic_to_message(missing.diagnostic.clone());
assert!(missing_msg.contains("NonExistent"), "missing export: {missing_msg}");
assert!(missing_msg.contains("provider"), "target module: {missing_msg}");
assert!(missing_msg.contains("consumer"), "importing module: {missing_msg}");
assert!(
missing_msg.contains("NonExistent"),
"missing export: {missing_msg}"
);
assert!(
missing_msg.contains("provider"),
"target module: {missing_msg}"
);
assert!(
missing_msg.contains("consumer"),
"importing module: {missing_msg}"
);
let (line, col) = diag_line_col(missing, missing_export, "consumer.dag");
assert_eq!(line, 2, "span should be on import line");
assert_eq!(col, 19, "span should point at missing name, not import keyword");
assert_eq!(
col, 19,
"span should point at missing name, not import keyword"
);

let unresolved = "module consumer\nimport nonexistent { Thing }\n";
let unresolved_result = compile_multi(module_index, &[("consumer.dag", unresolved)]);
Expand Down Expand Up @@ -286,8 +302,7 @@ fn type_and_arity_discrimination(module_index: &ModuleIndex) {
diagnostic_messages(&parameterized_result)
);

let user_defined =
"module custom\ntype Widget { label: String }\ntype Bag { item: Widget }\n";
let user_defined = "module custom\ntype Widget { label: String }\ntype Bag { item: Widget }\n";
let user_defined_result = compile_multi(module_index, &[("custom.dag", user_defined)]);
assert!(
!has_arity_mismatch(&user_defined_result),
Expand Down Expand Up @@ -319,7 +334,8 @@ fn empty_list_literal_context(module_index: &ModuleIndex) {
diagnostic_messages(&wrong_result)
);

let ok = "module elist_ok\nimport std.types { List }\nfn make_list() -> List<String> {\n []\n}\n";
let ok =
"module elist_ok\nimport std.types { List }\nfn make_list() -> List<String> {\n []\n}\n";
let ok_result = compile_multi(module_index, &[("elist_ok.dag", ok)]);
let ok_diags: Vec<_> = ok_result
.diagnostics
Expand Down
Loading
Loading