diff --git a/repl_test/src/wasm.rs b/repl_test/src/wasm.rs index be0e346a1c..13fd82f6f2 100644 --- a/repl_test/src/wasm.rs +++ b/repl_test/src/wasm.rs @@ -18,8 +18,7 @@ thread_local! { // The compiler Wasm instance. // This takes several *seconds* to initialise, so we only want to do it once for all tests. // Every test mutates compiler memory in `unsafe` ways, so we run them sequentially using a Mutex. -// Even if Cargo uses many threads, these tests won't go any faster, and that's OK. -// Note: I tried cloning this to thread_locals but it contains an Arc so we can't make a deep clone. +// Even if Cargo uses many threads, these tests won't go any faster. But that's fine, they're quick. lazy_static! { static ref COMPILER: Instance = init_compiler(); static ref TEST_MUTEX: Mutex<()> = Mutex::new(()); @@ -48,7 +47,7 @@ fn init_compiler() -> Instance { } }; - // This takes 5 seconds on my machine + // This is the slow line Instance::new(&wasmer_module, &import_object).unwrap() } @@ -74,12 +73,12 @@ fn wasmer_create_app(app_bytes_ptr: u32, app_bytes_len: u32) -> u32 { let wasmer_module = match Module::new(&store, app_module_bytes) { Ok(m) => m, Err(e) => { - let path = "/tmp/roc_repl_test_invalid_app.wasm"; - fs::write(path, app_module_bytes).unwrap(); - println!( - "Failed to create Wasm module\nWrote invalid wasm to {}\n{:?}", - path, e - ); + println!("Failed to create Wasm module\n{:?}", e); + if false { + let path = "/tmp/roc_repl_test_invalid_app.wasm"; + fs::write(path, app_module_bytes).unwrap(); + println!("Wrote invalid wasm to {}", path); + } return false.into(); } }; diff --git a/repl_www/README.md b/repl_www/README.md index 16e0f8c1e8..c7f7242c7e 100644 --- a/repl_www/README.md +++ b/repl_www/README.md @@ -2,7 +2,7 @@ ## Running locally -1. Run the build script +### 1. Run the build script This builds the compiler as a `.wasm` file, and generates JS glue code. It will `cargo install` the `wasm-pack` command line tool if you don't already have it. @@ -14,7 +14,7 @@ You should run it from the project root directory. All the final assets for the web REPL will end up in `./repl_www/build/` -2. Run a local HTTP server +### 2. Run a local HTTP server Browsers won't load .wasm files over the `file://` protocol, so you need to serve the files in `./repl_www/build/` from a local web server. Any server will do, but this example should work on any system that has Python 3 installed: @@ -24,8 +24,10 @@ cd repl_www/build python3 -m http.server ``` -Then you should be able to find the Roc REPL at `http://127.0.0.1:8000` -Warning: Not all language features are working perfectly yet! +### 3. Open your browser +You should be able to find the Roc REPL at http://127.0.0.1:8000 (or wherever your web server said when it started up.) + +**Warning:** This is work in progress! Not all language features are implemented yet, error messages don't look nice yet, up/down arrows don't work for history, etc. ![Screenshot](./screenshot.png)