This commit is contained in:
Luke Boswell 2024-09-03 20:35:56 +10:00
parent 012a2fc63f
commit a11f51a315
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
2 changed files with 34 additions and 59 deletions

View file

@ -1,5 +1,3 @@
app [main] { pf: platform "main.roc" } app [main] { pf: platform "main.roc" }
import pf.Task main = Task.ok {}
main = Task.succeed {}

View file

@ -56,30 +56,30 @@ mod cli_run {
PlainText(&'a str), PlainText(&'a str),
} }
fn check_compile_error(file: &Path, flags: &[&str], expected: &str) { // fn check_compile_error(file: &Path, flags: &[&str], expected: &str) {
check_compile_error_with(CMD_CHECK, file, flags, expected); // check_compile_error_with(CMD_CHECK, file, flags, expected);
} // }
fn check_compile_error_with(cmd: &str, file: &Path, flags: &[&str], expected: &str) { // fn check_compile_error_with(cmd: &str, file: &Path, flags: &[&str], expected: &str) {
let compile_out = run_roc([cmd, file.to_str().unwrap()].iter().chain(flags), &[], &[]); // let compile_out = run_roc([cmd, file.to_str().unwrap()].iter().chain(flags), &[], &[]);
let err = compile_out.stdout.trim(); // let err = compile_out.stdout.trim();
let err = strip_colors(err); // let err = strip_colors(err);
#[cfg_attr(windows, ignore)] // #[cfg_attr(windows, ignore)]
// uses C platform // // uses C platform
fn platform_switching_main() { // fn platform_switching_main() {
let expected_ending = "Which platform am I running on now?\n🔨 Building host ...\n"; // let expected_ending = "Which platform am I running on now?\n🔨 Building host ...\n";
let runner = Run::new_roc() // let runner = Run::new_roc()
.arg(CMD_RUN) // .arg(CMD_RUN)
.arg(BUILD_HOST_FLAG) // .arg(BUILD_HOST_FLAG)
.arg(SUPPRESS_BUILD_HOST_WARNING_FLAG) // .arg(SUPPRESS_BUILD_HOST_WARNING_FLAG)
.add_arg_if(LINKER_FLAG, TEST_LEGACY_LINKER) // .add_arg_if(LINKER_FLAG, TEST_LEGACY_LINKER)
.with_valigrind(ALLOW_VALGRIND) // .with_valigrind(ALLOW_VALGRIND)
.arg(file_from_root("examples/platform-switching", "main.roc").as_path()); // .arg(file_from_root("examples/platform-switching", "main.roc").as_path());
let out = runner.run(); // let out = runner.run();
out.assert_clean_success(); // out.assert_clean_success();
out.assert_stdout_and_stderr_ends_with(expected_ending); // out.assert_stdout_and_stderr_ends_with(expected_ending);
} // }
// We exclude the C platforming switching example // We exclude the C platforming switching example
// because the main platform switching example runs the c platform. // because the main platform switching example runs the c platform.
@ -454,6 +454,7 @@ mod cli_run {
out.assert_stdout_and_stderr_ends_with(expected_ending); out.assert_stdout_and_stderr_ends_with(expected_ending);
} }
#[ignore = "likely broken because of alias analysis: https://github.com/roc-lang/roc/issues/6544"]
#[test] #[test]
#[cfg_attr(any(target_os = "windows", target_os = "linux"), ignore = "Segfault")] #[cfg_attr(any(target_os = "windows", target_os = "linux"), ignore = "Segfault")]
fn false_interpreter() { fn false_interpreter() {
@ -1197,13 +1198,14 @@ mod cli_run {
fn known_type_error() { fn known_type_error() {
let expected_ending = indoc!( let expected_ending = indoc!(
r#" r#"
TYPE MISMATCH in tests/known_bad/TypeError.roc TYPE MISMATCH in tests/known_bad/TypeError.roc
Something is off with the body of the main definition: Something is off with the body of the main definition:
5 main : Str -> Task {} [] 3 main : Str -> Task {} []
6 main = \_ -> 4 main = \_ ->
7 "this is a string, not a Task {} [] function like the platform expects." 5 "this is a string, not a Task {} [] function like the platform expects."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The body is a string of type: The body is a string of type:
@ -1215,6 +1217,11 @@ mod cli_run {
Task {} [] Task {} []
Tip: Add type annotations to functions or values to help you figure Tip: Add type annotations to functions or values to help you figure
this out.
1 error and 0 warning found in <ignored for test> ms
"# "#
); );
@ -1316,36 +1323,6 @@ mod cli_run {
.assert_stdout_and_stderr_ends_with(expected_ending); .assert_stdout_and_stderr_ends_with(expected_ending);
} }
#[test]
fn unknown_generates_with() {
let expected_ending = indoc!(
r#"
UNKNOWN GENERATES FUNCTION in tests/known_bad/UnknownGeneratesWith.roc
I don't know how to generate the foobar function.
4 generates Effect with [after, map, always, foobar]
^^^^^^
more about hosted modules at TODO.
1 error and 0 warning found in <ignored for test> ms
"#
);
Run::new_roc()
.arg(CMD_CHECK)
.arg(file_from_root(
"crates/cli/tests/known_bad",
"UnknownGeneratesWith.roc",
))
.run()
.assert_stdout_and_stderr_ends_with(expected_ending);
}
#[test] #[test]
fn format_check_good() { fn format_check_good() {
Run::new_roc() Run::new_roc()