File tree Expand file tree Collapse file tree 5 files changed +42
-2
lines changed
Expand file tree Collapse file tree 5 files changed +42
-2
lines changed Original file line number Diff line number Diff line change 5151 run : make -C tests/simple run-base
5252 - name : Build and run wevaled 'simple' test
5353 run : make -C tests/simple run-wevaled
54+
55+ test-js :
56+ runs-on : ubuntu-latest
57+ steps :
58+ - uses : actions/checkout@v4
59+ - uses : actions/setup-node@v4
60+ with :
61+ node-version : latest
62+ - run : npm install
63+ working-directory : npm/weval
64+ - run : npm test
65+ working-directory : npm/weval
Original file line number Diff line number Diff line change @@ -14,7 +14,14 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1414
1515const TAG = "v0.3.2" ;
1616
17- async function getWeval ( ) {
17+ /**
18+ * Download Weval from GitHub releases
19+ *
20+ * @param {object } [opts]
21+ * @param {string } [opts.downloadDir] - Directory to which the binary should be downloaded
22+ * @returns {string } path to the downloaded binary on disk
23+ */
24+ export async function getWeval ( opts ) {
1825 const knownPlatforms = {
1926 "win32 x64 LE" : "x86_64-windows" ,
2027 "darwin arm64 LE" : "aarch64-macos" ,
@@ -38,7 +45,7 @@ async function getWeval() {
3845 const assetSuffix = platform == "win32" ? "zip" : "tar.xz" ;
3946 const exeSuffix = platform == "win32" ? ".exe" : "" ;
4047
41- const exeDir = join ( __dirname , platformName ) ;
48+ const exeDir = join ( opts && opts . downloadDir ? opts . downloadDir : __dirname , platformName ) ;
4249 const exe = join ( exeDir , `weval${ exeSuffix } ` ) ;
4350
4451 // If we already have the executable installed, then return it
Original file line number Diff line number Diff line change 44 "description" : " The WebAssembly partial evaluator" ,
55 "type" : " module" ,
66 "scripts" : {
7+ "test" : " node ./tests/index.mjs" ,
78 "version" : " node ./update.js $npm_package_version"
89 },
910 "dependencies" : {
Original file line number Diff line number Diff line change 1+ import assert from "node:assert" ;
2+ import { test } from "node:test" ;
3+ import { tmpdir } from "node:os" ;
4+ import { join } from "node:path" ;
5+ import { mkdtemp , access } from 'node:fs/promises' ;
6+
7+ import { getWeval } from "../index.js" ;
8+
9+ export default async function tests ( ) {
10+ test ( "downloading works" , async ( ) => {
11+ const downloadDir = await mkdtemp ( join ( tmpdir ( ) , "weval-dl-" ) ) ;
12+ const wevalPath = await getWeval ( { downloadDir } ) ;
13+ assert ( wevalPath ) ;
14+ await access ( wevalPath ) ;
15+ console . log ( `weval path: ${ wevalPath } ` ) ;
16+ } ) ;
17+ }
Original file line number Diff line number Diff line change 1+ import { default as downloadTests } from "./download.mjs" ;
2+
3+ await downloadTests ( ) ;
You can’t perform that action at this time.
0 commit comments