Skip to content

Commit 103c5ad

Browse files
authored
wasm: attempt to GC in tests (#7400)
1 parent 82eb186 commit 103c5ad

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

.github/workflows/wasm.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
source $(dirname $(which emsdk))/emsdk_env.sh
4949
which node
5050
which clang++
51-
npm run build:wasm -- -sINITIAL_MEMORY=128MB -sALLOW_MEMORY_GROWTH
51+
npm run build:wasm
5252
5353
- name: Test
5454
run: npm test

src/api/js/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"clean": "rimraf build 'src/**/*.__GENERATED__.*'",
3030
"lint": "prettier -c '{./,src/,scripts/,examples/}**/*.{js,ts}'",
3131
"format": "prettier --write '{./,src/,scripts/}**/*.{js,ts}'",
32-
"test": "jest",
32+
"test": "node --expose-gc ./node_modules/.bin/jest",
3333
"docs": "typedoc",
3434
"check-engine": "check-engine"
3535
},

src/api/js/scripts/build-wasm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const fns = JSON.stringify(exportedFuncs());
6969
const methods = '["ccall","FS","allocate","UTF8ToString","intArrayFromString","ALLOC_NORMAL"]';
7070
const libz3a = path.normalize('../../../build/libz3.a');
7171
spawnSync(
72-
`emcc build/async-fns.cc ${libz3a} --std=c++20 --pre-js src/low-level/async-wrapper.js -g2 -pthread -fexceptions -s WASM_BIGINT -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=0 -s PTHREAD_POOL_SIZE_STRICT=0 -s MODULARIZE=1 -s 'EXPORT_NAME="initZ3"' -s EXPORTED_RUNTIME_METHODS=${methods} -s EXPORTED_FUNCTIONS=${fns} -s DISABLE_EXCEPTION_CATCHING=0 -s SAFE_HEAP=0 -s DEMANGLE_SUPPORT=1 -s TOTAL_MEMORY=1GB -s TOTAL_STACK=20MB -I z3/src/api/ -o build/z3-built.js`,
72+
`emcc build/async-fns.cc ${libz3a} --std=c++20 --pre-js src/low-level/async-wrapper.js -g2 -pthread -fexceptions -s WASM_BIGINT -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=0 -s PTHREAD_POOL_SIZE_STRICT=0 -s MODULARIZE=1 -s 'EXPORT_NAME="initZ3"' -s EXPORTED_RUNTIME_METHODS=${methods} -s EXPORTED_FUNCTIONS=${fns} -s DISABLE_EXCEPTION_CATCHING=0 -s SAFE_HEAP=0 -s DEMANGLE_SUPPORT=1 -s TOTAL_MEMORY=2GB -s TOTAL_STACK=20MB -I z3/src/api/ -o build/z3-built.js`,
7373
);
7474

7575
fs.rmSync(ccWrapperPath);

src/api/js/src/high-level/high-level.test.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { init, killThreads } from '../jest';
44
import { Arith, Bool, Model, Quantifier, Z3AssertionError, Z3HighLevel, AstVector } from './types';
55
import { expectType } from 'ts-expect';
66

7+
// this should not be necessary but there may be a Jest bug
8+
// https://github.com/jestjs/jest/issues/7874
9+
afterEach(() => {
10+
global.gc && global.gc();
11+
});
12+
713
/**
814
* Generate all possible solutions from given assumptions.
915
*
@@ -356,8 +362,7 @@ describe('high-level', () => {
356362
});
357363

358364

359-
describe('bitvectors', () => {
360-
/**
365+
describe('bitvectors', () => {
361366
it('can do simple proofs', async () => {
362367
const { BitVec, Concat, Implies, isBitVecVal } = api.Context('main');
363368

@@ -376,7 +381,6 @@ describe('high-level', () => {
376381

377382
await prove(Implies(Concat(x, y).eq(Concat(y, x)), x.eq(y)));
378383
});
379-
**/
380384

381385
it('finds x and y such that: x ^ y - 103 == x * y', async () => {
382386
const { BitVec, isBitVecVal } = api.Context('main');

0 commit comments

Comments
 (0)