Error when platform package config cannot be found

This avoid compiler hangs that occurred before

Closes #1822
This commit is contained in:
ayazhafiz 2022-01-29 01:59:47 -05:00
parent 8633cedf4d
commit f28ca65ac5
3 changed files with 42 additions and 23 deletions

View file

@ -1217,6 +1217,10 @@ impl<'a> LoadStart<'a> {
let buf = to_parse_problem_report(problem, module_ids, root_exposed_ident_ids); let buf = to_parse_problem_report(problem, module_ids, root_exposed_ident_ids);
return Err(LoadingProblem::FormattedReport(buf)); return Err(LoadingProblem::FormattedReport(buf));
} }
Err(LoadingProblem::FileProblem { filename, error }) => {
let buf = to_file_problem_report(&filename, error);
return Err(LoadingProblem::FormattedReport(buf));
}
Err(e) => return Err(e), Err(e) => return Err(e),
} }
}; };
@ -1367,7 +1371,7 @@ where
// We need to allocate worker *queues* on the main thread and then move them // We need to allocate worker *queues* on the main thread and then move them
// into the worker threads, because those workers' stealers need to be // into the worker threads, because those workers' stealers need to be
// shared bet,een all threads, and this coordination work is much easier // shared between all threads, and this coordination work is much easier
// on the main thread. // on the main thread.
let mut worker_queues = bumpalo::collections::Vec::with_capacity_in(num_workers, arena); let mut worker_queues = bumpalo::collections::Vec::with_capacity_in(num_workers, arena);
let mut stealers = bumpalo::collections::Vec::with_capacity_in(num_workers, arena); let mut stealers = bumpalo::collections::Vec::with_capacity_in(num_workers, arena);
@ -1745,7 +1749,7 @@ fn update<'a>(
state.module_cache.module_names.insert(*id, name.clone()); state.module_cache.module_names.insert(*id, name.clone());
} }
// This was a dependency. Write it down and keep processing messaages. // This was a dependency. Write it down and keep processing messages.
let mut exposed_symbols: MutSet<Symbol> = let mut exposed_symbols: MutSet<Symbol> =
HashSet::with_capacity_and_hasher(header.exposes.len(), default_hasher()); HashSet::with_capacity_and_hasher(header.exposes.len(), default_hasher());
@ -2638,7 +2642,10 @@ fn parse_header<'a>(
Msg::Many(vec![app_module_header_msg, load_pkg_config_msg]), Msg::Many(vec![app_module_header_msg, load_pkg_config_msg]),
)) ))
} else { } else {
Ok((module_id, app_module_header_msg)) Err(LoadingProblem::FileProblem {
filename: pkg_config_roc,
error: io::ErrorKind::NotFound.into(),
})
} }
} else { } else {
panic!("could not find base") panic!("could not find base")

View file

@ -1,7 +1,6 @@
app "primary" interface Primary
packages { blah: "./blah" } exposes [ blah2, blah3, str, alwaysThree, identity, z, w, succeed, withDefault, yay ]
imports [ Dep1, Dep2.{ two, foo }, Dep3.Blah.{ bar }, Res ] imports [ Dep1, Dep2.{ two, foo }, Dep3.Blah.{ bar }, Res ]
provides [ blah2, blah3, str, alwaysThree, identity, z, w, succeed, withDefault, yay ] to blah
blah2 = Dep2.two blah2 = Dep2.two
blah3 = bar blah3 = bar

View file

@ -82,11 +82,6 @@ mod test_load {
let app_module = files.pop().unwrap(); let app_module = files.pop().unwrap();
let interfaces = files; let interfaces = files;
debug_assert!(
app_module.1.starts_with("app"),
"The final module should be the application module"
);
for (name, source) in interfaces { for (name, source) in interfaces {
let mut filename = PathBuf::from(name); let mut filename = PathBuf::from(name);
filename.set_extension("roc"); filename.set_extension("roc");
@ -278,15 +273,10 @@ mod test_load {
"Main", "Main",
indoc!( indoc!(
r#" r#"
app "test-app" interface Other exposes [ empty ] imports [ RBTree ]
packages { blah: "./blah" }
imports [ RBTree ]
provides [ main ] to blah
empty : RBTree.RedBlackTree I64 I64 empty : RBTree.RedBlackTree I64 I64
empty = RBTree.empty empty = RBTree.empty
main = empty
"# "#
), ),
), ),
@ -530,7 +520,7 @@ mod test_load {
"Main", "Main",
indoc!( indoc!(
r#" r#"
app "test-app" packages { blah: "./blah" } provides [ main ] to blah interface Main exposes [ main ] imports []
main = [ main = [
"# "#
@ -561,9 +551,7 @@ mod test_load {
} }
#[test] #[test]
#[should_panic( #[should_panic(expected = "FILE NOT FOUND")]
expected = "FileProblem { filename: \"tests/fixtures/build/interface_with_deps/invalid$name.roc\", error: NotFound }"
)]
fn file_not_found() { fn file_not_found() {
let subs_by_module = MutMap::default(); let subs_by_module = MutMap::default();
let loaded_module = load_fixture("interface_with_deps", "invalid$name", subs_by_module); let loaded_module = load_fixture("interface_with_deps", "invalid$name", subs_by_module);
@ -589,4 +577,29 @@ mod test_load {
}, },
); );
} }
#[test]
fn platform_does_not_exist() {
let modules = vec![(
"Main",
indoc!(
r#"
app "example"
packages { pf: "./zzz-does-not-exist" }
imports [ ]
provides [ main ] to pf
main = ""
"#
),
)];
match multiple_modules(modules) {
Err(report) => {
assert!(report.contains("FILE NOT FOUND"));
assert!(report.contains("zzz-does-not-exist/Package-Config.roc"));
}
Ok(_) => unreachable!("we expect failure here"),
}
}
} }