From 5af79f634b7431e886b254992e7fbdbe044d1e9d Mon Sep 17 00:00:00 2001 From: David Campion Date: Wed, 19 Jan 2022 17:08:28 -0800 Subject: [PATCH] doc(repo): Update contributing docs (#3298) --- CONTRIBUTING.md | 44 ++++++++++++++++++++++++----------- crates/swc/tests/error_msg.rs | 2 +- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8191632d421..75194b5ddda 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,41 +65,59 @@ Steps to get started: ## Getting your development environment set up -After cloning the project there are a few steps required to get the project running. +After cloning the project there are a few steps required to get the project running. +For running all tests, take the following steps: -1. Fetch submodules to pull ECMAScript test suites. +1. Fetch submodules to pull ECMAScript test suites. ```bash git submodule update --init --recursive ``` -2. Install js dependencies. +2. Install js dependencies. + Ensure [Yarn Package Manager is installed](https://yarnpkg.com/getting-started/install) - ```bash - yarn - ( cd crates/swc_ecma_transforms; yarn ) - ``` + ```bash + yarn + ``` -3. Setup some environment variables which is required for tests. +3. Setup some environment variables which is required for tests. ```bash export RUST_BACKTRACE=full - export PATH="$PATH:$PWD/crates/swc_ecma_transforms/node_modules/.bin" + export PATH="$PATH:$PWD/node_modules/.bin" export RUST_MIN_STACK=16777216 ``` -4. Install deno, if you are going to work on the bundler. +4. Install deno See [official install guide of deno](https://deno.land/manual/getting_started/installation) to install it. -5. Ensure you're using Node.JS >= 16 +5. Add wasm32-wasi target + + `rustup target add wasm32-wasi` + +6. Ensure you're using Node.JS >= 16 Since tests make use of `atob` which was only introduced in node 16. -6. Run tests +7. Run tests ```bash - cargo test --all --all-features + cargo test --all --no-default-features --features swc_v1 + ``` + Or + ```bash + cargo test --all --no-default-features --features swc_v2 + ``` + +## Running tests per package + +While working on specific packages, individual tests can be run by specifying a package to the +cargo test runner, e.g. + + ```bash + cargo test -p swc_ecma_transforms --all-features ``` ## Pull requests diff --git a/crates/swc/tests/error_msg.rs b/crates/swc/tests/error_msg.rs index ebea4718a5e..307380cd68e 100644 --- a/crates/swc/tests/error_msg.rs +++ b/crates/swc/tests/error_msg.rs @@ -73,7 +73,7 @@ fn fixture(input: PathBuf) { }) .expect_err("should fail"); - let output = NormalizedOutput::from(format!("{:?}", err)); + let output = NormalizedOutput::from(format!("{}", err)); output.compare_to_file(&output_path).unwrap(); }