mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
Merge pull request #2418 from rtfeldman/i/1822
Error when platform package config cannot be found
This commit is contained in:
commit
00617ebf2a
6 changed files with 67 additions and 29 deletions
|
@ -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());
|
||||||
|
|
||||||
|
@ -2645,7 +2649,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,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic!("could not find base")
|
panic!("could not find base")
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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"),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,11 +56,7 @@ mod insert_doc_syntax_highlighting {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const HELLO_WORLD: &str = r#"
|
pub const HELLO_WORLD: &str = r#"interface Test exposes [ ] imports [ ]
|
||||||
app "test-app"
|
|
||||||
packages { pf: "platform" }
|
|
||||||
imports []
|
|
||||||
provides [ main ] to pf
|
|
||||||
|
|
||||||
main = "Hello, world!"
|
main = "Hello, world!"
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ impl<'a> EdModule<'a> {
|
||||||
pub mod test_ed_model {
|
pub mod test_ed_model {
|
||||||
use crate::editor::ed_error::EdResult;
|
use crate::editor::ed_error::EdResult;
|
||||||
use crate::editor::mvc::ed_model;
|
use crate::editor::mvc::ed_model;
|
||||||
use crate::editor::resources::strings::HELLO_WORLD;
|
use crate::editor::resources::strings::{HELLO_WORLD, PLATFORM_STR};
|
||||||
use crate::ui::text::caret_w_select::test_caret_w_select::convert_dsl_to_selection;
|
use crate::ui::text::caret_w_select::test_caret_w_select::convert_dsl_to_selection;
|
||||||
use crate::ui::text::caret_w_select::test_caret_w_select::convert_selection_to_dsl;
|
use crate::ui::text::caret_w_select::test_caret_w_select::convert_selection_to_dsl;
|
||||||
use crate::ui::text::caret_w_select::CaretPos;
|
use crate::ui::text::caret_w_select::CaretPos;
|
||||||
|
@ -222,6 +222,7 @@ pub mod test_ed_model {
|
||||||
use roc_module::symbol::IdentIds;
|
use roc_module::symbol::IdentIds;
|
||||||
use roc_module::symbol::ModuleIds;
|
use roc_module::symbol::ModuleIds;
|
||||||
use roc_types::subs::VarStore;
|
use roc_types::subs::VarStore;
|
||||||
|
use std::fs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -290,6 +291,15 @@ pub mod test_ed_model {
|
||||||
*clean_code_str = full_code.join("\n");
|
*clean_code_str = full_code.join("\n");
|
||||||
|
|
||||||
let temp_dir = tempdir().expect("Failed to create temporary directory for test.");
|
let temp_dir = tempdir().expect("Failed to create temporary directory for test.");
|
||||||
|
|
||||||
|
let platform_dir = temp_dir.path().join("platform");
|
||||||
|
fs::create_dir(platform_dir.clone()).expect("Failed to create platform directory");
|
||||||
|
let package_config_path = platform_dir.join("Package-Config.roc");
|
||||||
|
let mut package_config_file =
|
||||||
|
File::create(package_config_path).expect("Failed to create Package-Config.roc");
|
||||||
|
writeln!(package_config_file, "{}", PLATFORM_STR)
|
||||||
|
.expect("Failed to write to Package-Config.roc");
|
||||||
|
|
||||||
let temp_file_path_buf =
|
let temp_file_path_buf =
|
||||||
PathBuf::from([Uuid::new_v4().to_string(), ".roc".to_string()].join(""));
|
PathBuf::from([Uuid::new_v4().to_string(), ".roc".to_string()].join(""));
|
||||||
let temp_file_full_path = temp_dir.path().join(temp_file_path_buf);
|
let temp_file_full_path = temp_dir.path().join(temp_file_path_buf);
|
||||||
|
|
|
@ -25,3 +25,16 @@ main = "Hello, world!"
|
||||||
|
|
||||||
|
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
|
pub const PLATFORM_STR: &str = r#"
|
||||||
|
platform "test-platform"
|
||||||
|
requires {} { main : Str }
|
||||||
|
exposes []
|
||||||
|
packages {}
|
||||||
|
imports []
|
||||||
|
provides [ mainForHost ]
|
||||||
|
effects fx.Effect {}
|
||||||
|
|
||||||
|
mainForHost : Str
|
||||||
|
mainForHost = main
|
||||||
|
"#;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue