From ec548d9143f015ca9ced25af6adf10ed3d7c152c Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 31 Aug 2022 13:21:53 -0400 Subject: [PATCH 1/7] Move Rust example --- crates/cli/tests/cli_run.rs | 2 +- .../platform-switching/{rust-platform => }/rocLovesRust.roc | 2 +- getting_started/linux_x86.md | 2 +- getting_started/macos_apple_silicon.md | 2 +- getting_started/macos_x86.md | 2 +- getting_started/other.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename examples/platform-switching/{rust-platform => }/rocLovesRust.roc (64%) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index 32d8180e0d..5fcb3dccc8 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -410,7 +410,7 @@ mod cli_run { // expected_ending:"Roc <3 C!\n", // use_valgrind: true, // }, - platformSwitchingRust:"platform-switching/rust-platform" => Example { + platformSwitchingRust:"platform-switching" => Example { filename: "rocLovesRust.roc", executable_filename: "rocLovesRust", stdin: &[], diff --git a/examples/platform-switching/rust-platform/rocLovesRust.roc b/examples/platform-switching/rocLovesRust.roc similarity index 64% rename from examples/platform-switching/rust-platform/rocLovesRust.roc rename to examples/platform-switching/rocLovesRust.roc index ce0da7a63c..7d9c8da26b 100644 --- a/examples/platform-switching/rust-platform/rocLovesRust.roc +++ b/examples/platform-switching/rocLovesRust.roc @@ -1,5 +1,5 @@ app "rocLovesRust" - packages { pf: "main.roc" } + packages { pf: "rust-platform/main.roc" } imports [] provides [main] to pf diff --git a/getting_started/linux_x86.md b/getting_started/linux_x86.md index fdedf4853a..d69da164fd 100644 --- a/getting_started/linux_x86.md +++ b/getting_started/linux_x86.md @@ -38,7 +38,7 @@ ```sh # Note: If you installed Rust in this terminal session, you'll need to open a new one first! - ./roc examples/platform-switching/rust-platform/rocLovesRust.roc + ./roc examples/platform-switching/rocLovesRust.roc ./roc examples/platform-switching/zig-platform/rocLovesZig.roc diff --git a/getting_started/macos_apple_silicon.md b/getting_started/macos_apple_silicon.md index de6c2b6332..56a5510554 100644 --- a/getting_started/macos_apple_silicon.md +++ b/getting_started/macos_apple_silicon.md @@ -34,7 +34,7 @@ ```sh # Note: If you installed rust in this terminal session, you'll need to open a new one first! - ./roc examples/platform-switching/rust-platform/rocLovesRust.roc + ./roc examples/platform-switching/rocLovesRust.roc ./roc examples/platform-switching/zig-platform/rocLovesZig.roc diff --git a/getting_started/macos_x86.md b/getting_started/macos_x86.md index fc88823b2f..31f5fabf07 100644 --- a/getting_started/macos_x86.md +++ b/getting_started/macos_x86.md @@ -34,7 +34,7 @@ ```sh # Note: If you installed rust in this terminal session, you'll need to open a new one first! - ./roc examples/platform-switching/rust-platform/rocLovesRust.roc + ./roc examples/platform-switching/rocLovesRust.roc ./roc examples/platform-switching/zig-platform/rocLovesZig.roc diff --git a/getting_started/other.md b/getting_started/other.md index 69b529c0bd..fcf40a75af 100644 --- a/getting_started/other.md +++ b/getting_started/other.md @@ -7,7 +7,7 @@ 1. Run examples: ```sh - cargo run examples/platform-switching/rust-platform/rocLovesRust.roc + cargo run examples/platform-switching/rocLovesRust.roc # This requires installing the Zig compiler, too. cargo run examples/platform-switching/zig-platform/rocLovesZig.roc From 841af10f36f9965d25e12bc5f99c49317bcab2e3 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 31 Aug 2022 13:39:24 -0400 Subject: [PATCH 2/7] move Swift example --- crates/cli/tests/cli_run.rs | 2 +- .../platform-switching/{swift-platform => }/rocLovesSwift.roc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename examples/platform-switching/{swift-platform => }/rocLovesSwift.roc (64%) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index 5fcb3dccc8..1cf0e79241 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -418,7 +418,7 @@ mod cli_run { expected_ending:"Roc <3 Rust!\n", use_valgrind: true, }, - platformSwitchingSwift:"platform-switching/swift-platform" => Example { + platformSwitchingSwift:"platform-switching" => Example { filename: "rocLovesSwift.roc", executable_filename: "rocLovesSwift", stdin: &[], diff --git a/examples/platform-switching/swift-platform/rocLovesSwift.roc b/examples/platform-switching/rocLovesSwift.roc similarity index 64% rename from examples/platform-switching/swift-platform/rocLovesSwift.roc rename to examples/platform-switching/rocLovesSwift.roc index 9413607c5a..8dcf22a97f 100644 --- a/examples/platform-switching/swift-platform/rocLovesSwift.roc +++ b/examples/platform-switching/rocLovesSwift.roc @@ -1,5 +1,5 @@ app "rocLovesSwift" - packages { pf: "main.roc" } + packages { pf: "swift-platform/main.roc" } imports [] provides [main] to pf From 6ccd00abf43ba87e291608eb6cccb8e515395fba Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 31 Aug 2022 14:05:43 -0400 Subject: [PATCH 3/7] move C example --- crates/cli/tests/cli_run.rs | 2 +- examples/platform-switching/{c-platform => }/rocLovesC.roc | 2 +- getting_started/linux_x86.md | 2 +- getting_started/macos_apple_silicon.md | 2 +- getting_started/macos_x86.md | 2 +- getting_started/other.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename examples/platform-switching/{c-platform => }/rocLovesC.roc (64%) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index 1cf0e79241..23b51a9090 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -402,7 +402,7 @@ mod cli_run { // We exclude the C platforming switching example // because the main platform switching example runs the c platform. // If we don't a race condition leads to test flakiness. - // platformSwitchingC:"platform-switching/c-platform" => Example { + // platformSwitchingC:"platform-switching" => Example { // filename: "rocLovesC.roc", // executable_filename: "rocLovesC", // stdin: &[], diff --git a/examples/platform-switching/c-platform/rocLovesC.roc b/examples/platform-switching/rocLovesC.roc similarity index 64% rename from examples/platform-switching/c-platform/rocLovesC.roc rename to examples/platform-switching/rocLovesC.roc index 71e366a7b0..43e7f606f6 100644 --- a/examples/platform-switching/c-platform/rocLovesC.roc +++ b/examples/platform-switching/rocLovesC.roc @@ -1,5 +1,5 @@ app "rocLovesC" - packages { pf: "main.roc" } + packages { pf: "c-platform/main.roc" } imports [] provides [main] to pf diff --git a/getting_started/linux_x86.md b/getting_started/linux_x86.md index d69da164fd..d2f166bf25 100644 --- a/getting_started/linux_x86.md +++ b/getting_started/linux_x86.md @@ -42,5 +42,5 @@ ./roc examples/platform-switching/zig-platform/rocLovesZig.roc - ./roc examples/platform-switching/c-platform/rocLovesC.roc + ./roc examples/platform-switching/rocLovesC.roc ``` diff --git a/getting_started/macos_apple_silicon.md b/getting_started/macos_apple_silicon.md index 56a5510554..7ab37dc29c 100644 --- a/getting_started/macos_apple_silicon.md +++ b/getting_started/macos_apple_silicon.md @@ -38,5 +38,5 @@ ./roc examples/platform-switching/zig-platform/rocLovesZig.roc - ./roc examples/platform-switching/c-platform/rocLovesC.roc + ./roc examples/platform-switching/rocLovesC.roc ``` diff --git a/getting_started/macos_x86.md b/getting_started/macos_x86.md index 31f5fabf07..61def33aa7 100644 --- a/getting_started/macos_x86.md +++ b/getting_started/macos_x86.md @@ -38,5 +38,5 @@ ./roc examples/platform-switching/zig-platform/rocLovesZig.roc - ./roc examples/platform-switching/c-platform/rocLovesC.roc + ./roc examples/platform-switching/rocLovesC.roc ``` diff --git a/getting_started/other.md b/getting_started/other.md index fcf40a75af..2e4db190b1 100644 --- a/getting_started/other.md +++ b/getting_started/other.md @@ -13,5 +13,5 @@ cargo run examples/platform-switching/zig-platform/rocLovesZig.roc # This requires installing the `clang` C compiler, too. - cargo run examples/platform-switching/c-platform/rocLovesC.roc + cargo run examples/platform-switching/rocLovesC.roc ``` From bc7d62e94c3428441388909d90de924fd9fd3aad Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 31 Aug 2022 14:09:34 -0400 Subject: [PATCH 4/7] move Zig example --- crates/cli/tests/cli_run.rs | 2 +- examples/platform-switching/{zig-platform => }/rocLovesZig.roc | 2 +- getting_started/linux_x86.md | 2 +- getting_started/macos_apple_silicon.md | 2 +- getting_started/macos_x86.md | 2 +- getting_started/other.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename examples/platform-switching/{zig-platform => }/rocLovesZig.roc (64%) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index 23b51a9090..a4b83e201d 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -434,7 +434,7 @@ mod cli_run { expected_ending:"Roc <3 Web Assembly!\n", use_valgrind: true, }, - platformSwitchingZig:"platform-switching/zig-platform" => Example { + platformSwitchingZig:"platform-switching" => Example { filename: "rocLovesZig.roc", executable_filename: "rocLovesZig", stdin: &[], diff --git a/examples/platform-switching/zig-platform/rocLovesZig.roc b/examples/platform-switching/rocLovesZig.roc similarity index 64% rename from examples/platform-switching/zig-platform/rocLovesZig.roc rename to examples/platform-switching/rocLovesZig.roc index ad9bdfa733..fe838c5396 100644 --- a/examples/platform-switching/zig-platform/rocLovesZig.roc +++ b/examples/platform-switching/rocLovesZig.roc @@ -1,5 +1,5 @@ app "rocLovesZig" - packages { pf: "main.roc" } + packages { pf: "zig-platform/main.roc" } imports [] provides [main] to pf diff --git a/getting_started/linux_x86.md b/getting_started/linux_x86.md index d2f166bf25..7fffcfe88a 100644 --- a/getting_started/linux_x86.md +++ b/getting_started/linux_x86.md @@ -40,7 +40,7 @@ # Note: If you installed Rust in this terminal session, you'll need to open a new one first! ./roc examples/platform-switching/rocLovesRust.roc - ./roc examples/platform-switching/zig-platform/rocLovesZig.roc + ./roc examples/platform-switching/rocLovesZig.roc ./roc examples/platform-switching/rocLovesC.roc ``` diff --git a/getting_started/macos_apple_silicon.md b/getting_started/macos_apple_silicon.md index 7ab37dc29c..a3b294e3de 100644 --- a/getting_started/macos_apple_silicon.md +++ b/getting_started/macos_apple_silicon.md @@ -36,7 +36,7 @@ # Note: If you installed rust in this terminal session, you'll need to open a new one first! ./roc examples/platform-switching/rocLovesRust.roc - ./roc examples/platform-switching/zig-platform/rocLovesZig.roc + ./roc examples/platform-switching/rocLovesZig.roc ./roc examples/platform-switching/rocLovesC.roc ``` diff --git a/getting_started/macos_x86.md b/getting_started/macos_x86.md index 61def33aa7..339f3e80e2 100644 --- a/getting_started/macos_x86.md +++ b/getting_started/macos_x86.md @@ -36,7 +36,7 @@ # Note: If you installed rust in this terminal session, you'll need to open a new one first! ./roc examples/platform-switching/rocLovesRust.roc - ./roc examples/platform-switching/zig-platform/rocLovesZig.roc + ./roc examples/platform-switching/rocLovesZig.roc ./roc examples/platform-switching/rocLovesC.roc ``` diff --git a/getting_started/other.md b/getting_started/other.md index 2e4db190b1..70f01dd2e5 100644 --- a/getting_started/other.md +++ b/getting_started/other.md @@ -10,7 +10,7 @@ cargo run examples/platform-switching/rocLovesRust.roc # This requires installing the Zig compiler, too. - cargo run examples/platform-switching/zig-platform/rocLovesZig.roc + cargo run examples/platform-switching/rocLovesZig.roc # This requires installing the `clang` C compiler, too. cargo run examples/platform-switching/rocLovesC.roc From 55688e8fa2b5cf8249ba9aed93cb4188bb0d96b6 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 31 Aug 2022 14:20:25 -0400 Subject: [PATCH 5/7] move WebAssembly example --- crates/cli/tests/cli_run.rs | 2 +- .../{web-assembly-platform => }/rocLovesWebAssembly.roc | 2 +- examples/platform-switching/web-assembly-platform/README.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename examples/platform-switching/{web-assembly-platform => }/rocLovesWebAssembly.roc (64%) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index a4b83e201d..2c15613865 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -426,7 +426,7 @@ mod cli_run { expected_ending:"Roc <3 Swift!\n", use_valgrind: true, }, - platformSwitchingWebAssembly:"platform-switching/web-assembly-platform" => Example { + platformSwitchingWebAssembly:"platform-switching" => Example { filename: "rocLovesWebAssembly.roc", executable_filename: "rocLovesWebAssembly", stdin: &[], diff --git a/examples/platform-switching/web-assembly-platform/rocLovesWebAssembly.roc b/examples/platform-switching/rocLovesWebAssembly.roc similarity index 64% rename from examples/platform-switching/web-assembly-platform/rocLovesWebAssembly.roc rename to examples/platform-switching/rocLovesWebAssembly.roc index 6a67749d14..ff550ad37a 100644 --- a/examples/platform-switching/web-assembly-platform/rocLovesWebAssembly.roc +++ b/examples/platform-switching/rocLovesWebAssembly.roc @@ -1,5 +1,5 @@ app "rocLovesWebAssembly" - packages { pf: "main.roc" } + packages { pf: "web-assembly-platform/main.roc" } imports [] provides [main] to pf diff --git a/examples/platform-switching/web-assembly-platform/README.md b/examples/platform-switching/web-assembly-platform/README.md index 2e77e5a0f0..192ebc7041 100644 --- a/examples/platform-switching/web-assembly-platform/README.md +++ b/examples/platform-switching/web-assembly-platform/README.md @@ -3,8 +3,8 @@ To run this website, first compile either of these identical apps: ```bash -# Option A: Compile examples/platform-switching/web-assembly-platform/rocLovesWebAssembly.roc -cargo run -- build --target=wasm32 examples/platform-switching/web-assembly-platform/rocLovesWebAssembly.roc +# Option A: Compile examples/platform-switching/rocLovesWebAssembly.roc +cargo run -- build --target=wasm32 examples/platform-switching/rocLovesWebAssembly.roc # Option B: Compile examples/platform-switching/main.roc with `pf: "web-assembly-platform/main.roc"` and move the result cargo run -- build --target=wasm32 examples/platform-switching/main.roc From a1543b5cc48ff1bf720ad1ca5ec10bfd550a4ce4 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 2 Sep 2022 10:44:29 -0400 Subject: [PATCH 6/7] treat platform-switching similarly to benchmarks --- crates/cli/tests/cli_run.rs | 41 ++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index 53fdb85619..37a1615ca9 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -822,26 +822,35 @@ mod cli_run { let example_dir_name = entry.file_name().into_string().unwrap(); // TODO: Improve this with a more-dynamic approach. (Read all subdirectories?) - // Some platform-switching examples live in nested directories + // Some platform-switching examples live in nested directories, and + // the rocLovesFoo.roc examples live directly under the platform-switching directory if example_dir_name == "platform-switching" { - for sub_dir in [ - // We exclude the C platforming switching example - // because the main platform switching example runs the c platform. - // If we don't a race condition leads to test flakiness. - // "c-platform", - "rust-platform", - "swift-platform", - "web-assembly-platform", - "zig-platform", - ] { - all_examples.remove(format!("{}/{}", example_dir_name, sub_dir).as_str()).unwrap_or_else(|| { - panic!("The example directory {}/{}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", examples_dir, example_dir_name, sub_dir); - }); - } + // The subdirectory checks broke when we moved the rodLovesFoo.roc examples + // Treating the platform-switching directory similarly to the benchmarks directory for now + + all_examples.remove(example_dir_name.as_str()).unwrap_or_else(|| { + panic!("The example directory {}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", examples_dir, example_dir_name); + }); + + // for sub_dir in [ + // // We exclude the C platforming switching example + // // because the main platform switching example runs the c platform. + // // If we don't a race condition leads to test flakiness. + // // "c-platform", + // "rust-platform", + // "swift-platform", + // "web-assembly-platform", + // "zig-platform", + // ] { + // all_examples.remove(format!("{}/{}", example_dir_name, sub_dir).as_str()).unwrap_or_else(|| { + // panic!("The example directory {}/{}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", examples_dir, example_dir_name, sub_dir); + // }); + // } } // We test benchmarks separately - if example_dir_name != "benchmarks" { + // platform-switching examples are handled above + if example_dir_name != "benchmarks" && example_dir_name != "platform-switching" { all_examples.remove(example_dir_name.as_str()).unwrap_or_else(|| { panic!("The example directory {}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", examples_dir, example_dir_name); }); From 9c6c8de5b47740a42fd028b8c66f0600fbcf49b7 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sun, 4 Sep 2022 21:53:01 -0400 Subject: [PATCH 7/7] remove special handling of platform-switching examples --- crates/cli/tests/cli_run.rs | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index 37a1615ca9..aa85d8b483 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -821,36 +821,8 @@ mod cli_run { if entry.file_type().unwrap().is_dir() { let example_dir_name = entry.file_name().into_string().unwrap(); - // TODO: Improve this with a more-dynamic approach. (Read all subdirectories?) - // Some platform-switching examples live in nested directories, and - // the rocLovesFoo.roc examples live directly under the platform-switching directory - if example_dir_name == "platform-switching" { - // The subdirectory checks broke when we moved the rodLovesFoo.roc examples - // Treating the platform-switching directory similarly to the benchmarks directory for now - - all_examples.remove(example_dir_name.as_str()).unwrap_or_else(|| { - panic!("The example directory {}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", examples_dir, example_dir_name); - }); - - // for sub_dir in [ - // // We exclude the C platforming switching example - // // because the main platform switching example runs the c platform. - // // If we don't a race condition leads to test flakiness. - // // "c-platform", - // "rust-platform", - // "swift-platform", - // "web-assembly-platform", - // "zig-platform", - // ] { - // all_examples.remove(format!("{}/{}", example_dir_name, sub_dir).as_str()).unwrap_or_else(|| { - // panic!("The example directory {}/{}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", examples_dir, example_dir_name, sub_dir); - // }); - // } - } - // We test benchmarks separately - // platform-switching examples are handled above - if example_dir_name != "benchmarks" && example_dir_name != "platform-switching" { + if example_dir_name != "benchmarks" { all_examples.remove(example_dir_name.as_str()).unwrap_or_else(|| { panic!("The example directory {}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", examples_dir, example_dir_name); });