Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ rec {
nixpkgs.ocamlPackages.js_of_ocaml
nixpkgs.ocamlPackages.js_of_ocaml-ocamlbuild
nixpkgs.ocamlPackages.js_of_ocaml-ppx
nixpkgs.nodejs
nixpkgs.nodejs-10_x
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NodeJS 12 just came out. It uses V8 7.4, which would be in line with what dev defaults to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test just checks if the output is valid WebAssembly, we don't actually run anything.

];

buildPhase = ''
Expand All @@ -222,8 +222,10 @@ rec {
cp src/asc.js $out
'';

doInstallCheck = true;

installCheckPhase = ''
NODE_PATH=$out/ node test/node-test.js
NODE_PATH=$out/ node --experimental-wasm-mut-global --experimental-wasm-mv test/node-test.js
'';

});
Expand Down
10 changes: 5 additions & 5 deletions test/node-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const assert = require('assert');
process.on('unhandledRejection', error => { assert.fail(error); });

const assert = require('assert').strict;

// Load asc.js
const m = require('asc.js');
Expand All @@ -16,8 +18,7 @@ assert.equal(typeof(empty_wasm_plain.diagnostics), 'object');
assert.equal(empty_wasm_plain.diagnostics.length, 0);

// Check that the WebAssembly binary can be loaded
WebAssembly.compile(Buffer.from(empty_wasm_plain.code, 'ascii'))
.catch(err => assert.fail(err));
WebAssembly.compile(Buffer.from(empty_wasm_plain.code, 'ascii'));

// Now again for the definity module
assert.equal(typeof(empty_wasm_dfinity), 'object');
Expand All @@ -26,8 +27,7 @@ assert.equal(empty_wasm_dfinity.code.substr(4,4), '\1\0\0\0');
assert.equal(typeof(empty_wasm_dfinity.diagnostics), 'object');
assert.equal(empty_wasm_dfinity.diagnostics.length, 0);

WebAssembly.compile(Buffer.from(empty_wasm_dfinity.code, 'ascii'))
.catch(err => assert.fail(err));
WebAssembly.compile(Buffer.from(empty_wasm_dfinity.code, 'ascii'));

// The plain and the dfinity module should not be the same
assert.notEqual(empty_wasm_plain.code, empty_wasm_dfinity.code);
Expand Down