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
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,15 @@ jobs:
run: make -C tests/simple run-base
- name: Build and run wevaled 'simple' test
run: make -C tests/simple run-wevaled

test-js:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: latest
- run: npm install
working-directory: npm/weval
- run: npm test
working-directory: npm/weval
11 changes: 9 additions & 2 deletions npm/weval/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ const __dirname = dirname(fileURLToPath(import.meta.url));

const TAG = "v0.3.2";

async function getWeval() {
/**
* Download Weval from GitHub releases
*
* @param {object} [opts]
* @param {string} [opts.downloadDir] - Directory to which the binary should be downloaded
* @returns {string} path to the downloaded binary on disk
*/
export async function getWeval(opts) {
const knownPlatforms = {
"win32 x64 LE": "x86_64-windows",
"darwin arm64 LE": "aarch64-macos",
Expand All @@ -38,7 +45,7 @@ async function getWeval() {
const assetSuffix = platform == "win32" ? "zip" : "tar.xz";
const exeSuffix = platform == "win32" ? ".exe" : "";

const exeDir = join(__dirname, platformName);
const exeDir = join(opts && opts.downloadDir ? opts.downloadDir : __dirname, platformName);
const exe = join(exeDir, `weval${exeSuffix}`);

// If we already have the executable installed, then return it
Expand Down
1 change: 1 addition & 0 deletions npm/weval/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "The WebAssembly partial evaluator",
"type": "module",
"scripts": {
"test": "node ./tests/index.mjs",
"version": "node ./update.js $npm_package_version"
},
"dependencies": {
Expand Down
17 changes: 17 additions & 0 deletions npm/weval/tests/download.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import assert from "node:assert";
import { test } from "node:test";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { mkdtemp, access } from 'node:fs/promises';

import { getWeval } from "../index.js";

export default async function tests() {
test("downloading works", async () => {
const downloadDir = await mkdtemp(join(tmpdir(), "weval-dl-"));
const wevalPath = await getWeval({ downloadDir });
assert(wevalPath);
await access(wevalPath);
console.log(`weval path: ${wevalPath}`);
});
}
3 changes: 3 additions & 0 deletions npm/weval/tests/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { default as downloadTests } from "./download.mjs";

await downloadTests();
Loading