Merge pull request #3943 from sandprickle/move-examples-3912

Move Platform Examples (3912)
This commit is contained in:
Jan Van Bruggen 2022-09-05 10:38:24 -06:00 committed by GitHub
commit 1272503bec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 24 additions and 43 deletions

View file

@ -386,7 +386,7 @@ mod cli_run {
// 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.
// If we don't a race condition leads to test flakiness. // If we don't a race condition leads to test flakiness.
// platformSwitchingC:"platform-switching/c-platform" => Example { // platformSwitchingC:"platform-switching" => Example {
// filename: "rocLovesC.roc", // filename: "rocLovesC.roc",
// executable_filename: "rocLovesC", // executable_filename: "rocLovesC",
// stdin: &[], // stdin: &[],
@ -394,7 +394,7 @@ mod cli_run {
// expected_ending:"Roc <3 C!\n", // expected_ending:"Roc <3 C!\n",
// use_valgrind: true, // use_valgrind: true,
// }, // },
platformSwitchingRust:"platform-switching/rust-platform" => Example { platformSwitchingRust:"platform-switching" => Example {
filename: "rocLovesRust.roc", filename: "rocLovesRust.roc",
executable_filename: "rocLovesRust", executable_filename: "rocLovesRust",
stdin: &[], stdin: &[],
@ -402,7 +402,7 @@ mod cli_run {
expected_ending:"Roc <3 Rust!\n", expected_ending:"Roc <3 Rust!\n",
use_valgrind: true, use_valgrind: true,
}, },
platformSwitchingSwift:"platform-switching/swift-platform" => Example { platformSwitchingSwift:"platform-switching" => Example {
filename: "rocLovesSwift.roc", filename: "rocLovesSwift.roc",
executable_filename: "rocLovesSwift", executable_filename: "rocLovesSwift",
stdin: &[], stdin: &[],
@ -410,7 +410,7 @@ mod cli_run {
expected_ending:"Roc <3 Swift!\n", expected_ending:"Roc <3 Swift!\n",
use_valgrind: true, use_valgrind: true,
}, },
platformSwitchingWebAssembly:"platform-switching/web-assembly-platform" => Example { platformSwitchingWebAssembly:"platform-switching" => Example {
filename: "rocLovesWebAssembly.roc", filename: "rocLovesWebAssembly.roc",
executable_filename: "rocLovesWebAssembly", executable_filename: "rocLovesWebAssembly",
stdin: &[], stdin: &[],
@ -418,7 +418,7 @@ mod cli_run {
expected_ending:"Roc <3 Web Assembly!\n", expected_ending:"Roc <3 Web Assembly!\n",
use_valgrind: true, use_valgrind: true,
}, },
platformSwitchingZig:"platform-switching/zig-platform" => Example { platformSwitchingZig:"platform-switching" => Example {
filename: "rocLovesZig.roc", filename: "rocLovesZig.roc",
executable_filename: "rocLovesZig", executable_filename: "rocLovesZig",
stdin: &[], stdin: &[],
@ -821,25 +821,6 @@ mod cli_run {
if entry.file_type().unwrap().is_dir() { if entry.file_type().unwrap().is_dir() {
let example_dir_name = entry.file_name().into_string().unwrap(); 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
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);
});
}
}
// We test benchmarks separately // We test benchmarks separately
if example_dir_name != "benchmarks" { if example_dir_name != "benchmarks" {
all_examples.remove(example_dir_name.as_str()).unwrap_or_else(|| { all_examples.remove(example_dir_name.as_str()).unwrap_or_else(|| {

View file

@ -1,5 +1,5 @@
app "rocLovesC" app "rocLovesC"
packages { pf: "main.roc" } packages { pf: "c-platform/main.roc" }
imports [] imports []
provides [main] to pf provides [main] to pf

View file

@ -1,5 +1,5 @@
app "rocLovesRust" app "rocLovesRust"
packages { pf: "main.roc" } packages { pf: "rust-platform/main.roc" }
imports [] imports []
provides [main] to pf provides [main] to pf

View file

@ -1,5 +1,5 @@
app "rocLovesSwift" app "rocLovesSwift"
packages { pf: "main.roc" } packages { pf: "swift-platform/main.roc" }
imports [] imports []
provides [main] to pf provides [main] to pf

View file

@ -1,5 +1,5 @@
app "rocLovesWebAssembly" app "rocLovesWebAssembly"
packages { pf: "main.roc" } packages { pf: "web-assembly-platform/main.roc" }
imports [] imports []
provides [main] to pf provides [main] to pf

View file

@ -1,5 +1,5 @@
app "rocLovesZig" app "rocLovesZig"
packages { pf: "main.roc" } packages { pf: "zig-platform/main.roc" }
imports [] imports []
provides [main] to pf provides [main] to pf

View file

@ -3,8 +3,8 @@
To run this website, first compile either of these identical apps: To run this website, first compile either of these identical apps:
```bash ```bash
# Option A: Compile examples/platform-switching/web-assembly-platform/rocLovesWebAssembly.roc # Option A: Compile examples/platform-switching/rocLovesWebAssembly.roc
cargo run -- build --target=wasm32 examples/platform-switching/web-assembly-platform/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 # 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 cargo run -- build --target=wasm32 examples/platform-switching/main.roc

View file

@ -38,9 +38,9 @@
```sh ```sh
# Note: If you installed Rust in this terminal session, you'll need to open a new one first! # 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 ./roc examples/platform-switching/rocLovesZig.roc
./roc examples/platform-switching/c-platform/rocLovesC.roc ./roc examples/platform-switching/rocLovesC.roc
``` ```

View file

@ -34,9 +34,9 @@
```sh ```sh
# Note: If you installed rust in this terminal session, you'll need to open a new one first! # 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 ./roc examples/platform-switching/rocLovesZig.roc
./roc examples/platform-switching/c-platform/rocLovesC.roc ./roc examples/platform-switching/rocLovesC.roc
``` ```

View file

@ -34,9 +34,9 @@
```sh ```sh
# Note: If you installed rust in this terminal session, you'll need to open a new one first! # 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 ./roc examples/platform-switching/rocLovesZig.roc
./roc examples/platform-switching/c-platform/rocLovesC.roc ./roc examples/platform-switching/rocLovesC.roc
``` ```

View file

@ -7,11 +7,11 @@
1. Run examples: 1. Run examples:
```sh ```sh
cargo run examples/platform-switching/rust-platform/rocLovesRust.roc cargo run examples/platform-switching/rocLovesRust.roc
# This requires installing the Zig compiler, too. # 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. # This requires installing the `clang` C compiler, too.
cargo run examples/platform-switching/c-platform/rocLovesC.roc cargo run examples/platform-switching/rocLovesC.roc
``` ```