Skip to content

Commit

Permalink
fix: fixed test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
alekitto committed Oct 26, 2023
1 parent 564eba7 commit 6ebbe9a
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 87 deletions.
58 changes: 51 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,29 @@ on:
pull_request_target:

jobs:
test_package:
name: Test
test_rust:
name: Test Rust
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [12, 18, 20]
fail-fast: false

steps:
- uses: actions/checkout@v4
name: Checkout source

- uses: actions/cache@v3
name: Setup Cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
simd-target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Run Rust tests
run: |
cargo install grcov
npm install -g mocha
cargo clean
cargo test
grcov . --binary-path ./target/debug -s . -t lcov --branch -o ./coverage.lcov
Expand All @@ -34,6 +42,40 @@ jobs:
with:
file: ./coverage.lcov

test_node:
name: Test (Node.JS ${{ matrix.node_version }})
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [14, 18, 20]
fail-fast: false

steps:
- uses: actions/checkout@v4
name: Checkout source

- uses: actions/cache@v3
name: Setup Cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
simd-target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- uses: actions/setup-node@v3
name: Setup Node.JS
with:
Expand All @@ -43,4 +85,6 @@ jobs:
run: |
cargo install wasm-pack
cargo clean
npm install -g mocha
npm ci
npm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/pkg
/simd
/target
/simd-target
/Cargo.lock
Expand Down
21 changes: 7 additions & 14 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
/node_modules/
/pkg/.gitignore
/pkg/package.json
/simd/.gitignore
/simd/package.json
/src/
/simd-target/
/target/
/tests/
/.gitignore
/.mocha*
/.yarnrc.yml
/Cargo.*
/yarn.lock
*

!/lib/*.js
!/pkg/compiler.*
!/simd/compiler.*
!/index.*
!/LICENSE
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build-release": "wasm-pack build --out-name compiler --target nodejs --release && RUSTFLAGS=\"-C target-feature=+simd128\" wasm-pack build --out-dir simd --out-name compiler --target nodejs --release --features=simd --target-dir=simd-target",
"build": "wasm-pack build --out-name compiler --target nodejs --dev && RUSTFLAGS=\"-C target-feature=+simd128\" wasm-pack build --out-dir simd --out-name compiler --target nodejs --dev --features=simd --target-dir=simd-target",
"pretest": "npm run build",
"test": "mocha tests/wasm/"
"test": "mocha tests/wasm/",
"prepublishOnly": "npm run build-release && bash -c 'rm {pkg,simd}/{.gitignore,package.json}'"
},
"main": "index.js",
"types": "index.d.ts",
Expand All @@ -18,7 +19,16 @@
"mocha": "^10.2.0",
"prettier": "^3.0.3"
},
"dependencies": {
"wasm-feature-detect": "^1.5.1"
}
"files": [
"index.js",
"index.d.ts",
"pkg/compiler.js",
"pkg/compiler.d.ts",
"pkg/compiler_bg.wasm",
"pkg/compiler_bg.wasm.d.ts",
"simd/compiler.js",
"simd/compiler.d.ts",
"simd/compiler_bg.wasm",
"simd/compiler_bg.wasm.d.ts"
]
}
62 changes: 0 additions & 62 deletions src/wasm/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,65 +39,3 @@ pub fn compile(

Ok(program.compile(CompileOptions { debug, namespace })?)
}

#[cfg(test)]
mod tests {
use crate::parse_uuid;
use crate::parser::{parse, CompileOptions};
use crate::reflection::get_reflection_data;
use crate::testing::uuid::reset_test_uuid;
use crate::wasm::reflection::get_js_reflection_data;

#[test]
pub fn should_compile_program_correctly() -> Result<(), Box<dyn std::error::Error>> {
reset_test_uuid();

let code = r#"
const a = () => Symbol('test');
const type = t => {
return function (value, context) {
console.log(value, context);
};
};
/** class docblock */
export default class x {
static #staticPrivateField;
#privateField;
accessor #privateAccessor;
static staticPublicField;
publicField;
accessor publicAccessor;
/**
* computed method docblock
*/
[a()]() {}
#privateMethod(a, b = 1, [c, d], {f, g}) {}
publicMethod({a, b} = {}, c = new Object(), ...x) {}
static #staticPrivateMethod() {}
static staticPublicMethod() {}
get [a()]() {}
set b(v) {}
get #ap() {}
set #bp(v) {}
act(@type(String) param1) {}
[a()](@type(String) param1) {}
[Symbol.for('xtest')](@type(String) param1) {}
}
"#;

let program = parse(code.to_string(), Some("x.js"))?;
let compiled = program.compile(CompileOptions {
debug: true,
namespace: None,
})?;

let data = get_js_reflection_data("00000000-0000-0000-0000-000000000000");

Ok(())
}
}

0 comments on commit 6ebbe9a

Please sign in to comment.