Skip to content

Commit

Permalink
Use mops to run tests (#579)
Browse files Browse the repository at this point in the history
- Changed test runner to `mops test`.
- Removed `vessel` dependency.
- Now only files with `// @Testmode wasi` comment line will be compiled
and run with wasmtime.

Mops can run tests in parallel, results:
On my laptop: 15s vs 50s
In GitHub CI: 30s vs 1m 33s

---------

Co-authored-by: Ryan Vandersmith <ryanvandersmith@gmail.com>
  • Loading branch information
ZenVoich and rvanasa authored Aug 2, 2023
1 parent 1bee37d commit f1f6099
Show file tree
Hide file tree
Showing 10 changed files with 6,146 additions and 410 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ jobs:
run: |
wget --output-document /home/runner/bin/vessel https://github.com/kritzcreek/vessel/releases/download/${{ env.vessel_version }}/vessel-linux64
chmod +x /home/runner/bin/vessel
- name: "test"
run: MOC_BINARY=moc npm test
- name: "test (interpreter mode)"
run: DFX_MOC_PATH=moc npm test
- name: "test (wasi mode)"
run: DFX_MOC_PATH=moc npm test -- --mode wasi
- name: "graph dependencies"
run: python3 doc/module_graph.py | dot -Tsvg > doc/module_graph.svg && file doc/module_graph.svg
- name: "docs"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ node_modules
# Unit testing
/test/generated
*.test.wasm

# Mops
.mops
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,32 @@ npm install
# Run tests
npm test

# Run all tests in wasi mode
npm test -- --mode wasi

# Run formatter
npm run prettier:format
```

The test runner will automatically detect the `moc` compiler from your system path or `dfx` installation.
The test runner will automatically detect the `moc` compiler from your system path or `dfx` installation.

Running the tests locally also requires [Wasmtime](https://wasmtime.dev/) and [Vessel](https://github.com/dfinity/vessel) to be installed on your system.

Run only specific test files:
```sh
npm test <filter>
```

For example `npm test list` will run `List.test.mo` and `AssocList.test.mo` test files.

Run tests in watch mode:
```sh
npm test -- --watch

# useful to combine with filter when writing tests
npm test array -- --watch
```

Documentation
-------------

Expand Down
3 changes: 3 additions & 0 deletions mops.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[dev-dependencies]
base = "./"
matchers = "https://github.com/kritzcreek/motoko-matchers#v1.3.0"
Loading

0 comments on commit f1f6099

Please sign in to comment.