From 50746330ccb6b21ed042ecbff0e205f0ff519835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Isager=20Dalsgar=C3=B0?= Date: Fri, 16 Feb 2024 15:56:18 +0100 Subject: [PATCH] Get addon tests running again --- .github/workflows/test.yml | 2 +- test/CMakeLists.txt | 13 ------------- test/addon-load.js | 6 +++--- test/addon-resolve.js | 7 ++++--- test/fixtures/CMakeLists.txt | 18 ++++++++++++++++-- test/fixtures/addon/CMakeLists.txt | 4 ++-- test/fixtures/bundle/CMakeLists.txt | 8 +++++++- test/helpers/.gitignore | 1 - test/helpers/build.json.in | 5 ----- test/import-addon.cjs | 5 +++-- test/import-addon.mjs | 5 +++-- 11 files changed, 39 insertions(+), 35 deletions(-) delete mode 100644 test/helpers/.gitignore delete mode 100644 test/helpers/build.json.in diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0988cafc..b4150439 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,7 +35,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - - run: npm install -g bare-dev + - run: npm install -g bare-runtime bare-dev - run: bare-dev configure --debug --platform ${{ matrix.platform }} --arch ${{ matrix.arch }} - run: bare-dev build --debug - run: bare-dev test --debug diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0ab9a9c4..b9441d4f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,19 +26,6 @@ list(APPEND tests timeout-clear.js ) -list(APPEND skipped_tests - addon-load.js - addon-resolve.js - import-addon.cjs - import-addon.mjs -) - -file( - GENERATE - OUTPUT ${CMAKE_CURRENT_LIST_DIR}/helpers/build.json - INPUT helpers/build.json.in -) - add_subdirectory(fixtures) foreach(file IN LISTS tests) diff --git a/test/addon-load.js b/test/addon-load.js index bde2824c..9e5130ca 100644 --- a/test/addon-load.js +++ b/test/addon-load.js @@ -1,8 +1,8 @@ /* global Bare */ const assert = require('bare-assert') -const os = require('bare-os') +const url = require('bare-url') const { Addon } = Bare -const addon = Addon.load(os.cwd()) +const addon = Addon.load(url.pathToFileURL(`./test/fixtures/addon/prebuilds/${Addon.host}/addon.bare`)) -assert(addon === 'Hello from addon') +assert(addon.exports === 'Hello from addon') diff --git a/test/addon-resolve.js b/test/addon-resolve.js index a985ef88..b0de0db8 100644 --- a/test/addon-resolve.js +++ b/test/addon-resolve.js @@ -1,8 +1,9 @@ /* global Bare */ const assert = require('bare-assert') const path = require('bare-path') -const os = require('bare-os') -const build = require('./helpers/build.json') +const url = require('bare-url') const { Addon } = Bare -assert(Addon.resolve(os.cwd()) === path.normalize(build.output.bare_addon)) +const resolved = Addon.resolve('.', url.pathToFileURL('./test/fixtures/addon/')) + +assert(url.fileURLToPath(resolved) == path.resolve('./test/fixtures/addon/prebuilds', Addon.host, 'addon.bare')) diff --git a/test/fixtures/CMakeLists.txt b/test/fixtures/CMakeLists.txt index d37293f3..7d07f975 100644 --- a/test/fixtures/CMakeLists.txt +++ b/test/fixtures/CMakeLists.txt @@ -1,2 +1,16 @@ -add_subdirectory(addon) -add_subdirectory(bundle) +find_bare_dev(bare_dev) + +list(APPEND fixtures + addon + bundle +) + +foreach(fixture ${fixtures}) + execute_process( + COMMAND "${bare_dev}" install --debug + OUTPUT_QUIET + ERROR_QUIET + WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/${fixture}" + COMMAND_ERROR_IS_FATAL ANY + ) +endforeach() diff --git a/test/fixtures/addon/CMakeLists.txt b/test/fixtures/addon/CMakeLists.txt index 51554c82..d18752a9 100644 --- a/test/fixtures/addon/CMakeLists.txt +++ b/test/fixtures/addon/CMakeLists.txt @@ -4,10 +4,10 @@ project(bare_addon C) include(bare) -add_bare_module(bare_addon) +add_bare_module(addon) target_sources( - ${bare_addon} + ${addon} PRIVATE binding.c ) diff --git a/test/fixtures/bundle/CMakeLists.txt b/test/fixtures/bundle/CMakeLists.txt index 7ebdc4b6..b66f9fc6 100644 --- a/test/fixtures/bundle/CMakeLists.txt +++ b/test/fixtures/bundle/CMakeLists.txt @@ -1,10 +1,16 @@ +cmake_minimum_required(VERSION 3.25) + +project(bare_addon C) + +include(bare) + add_bare_bundle( ENTRY mod.js OUT mod.bundle ) add_custom_target( - test_bundle + bundle ALL DEPENDS mod.bundle ) diff --git a/test/helpers/.gitignore b/test/helpers/.gitignore deleted file mode 100644 index 85b2aef5..00000000 --- a/test/helpers/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build.json diff --git a/test/helpers/build.json.in b/test/helpers/build.json.in deleted file mode 100644 index a6566f7f..00000000 --- a/test/helpers/build.json.in +++ /dev/null @@ -1,5 +0,0 @@ -{ - "output": { - "bare": "$" - } -} diff --git a/test/import-addon.cjs b/test/import-addon.cjs index ebc585fd..bf6f27cf 100644 --- a/test/import-addon.cjs +++ b/test/import-addon.cjs @@ -1,6 +1,7 @@ +/* global Bare */ const assert = require('bare-assert') -const build = require('./helpers/build.json') +const { Addon } = Bare -const mod = require(build.output.bare_addon) +const mod = require(`./fixtures/addon/prebuilds/${Addon.host}/addon.bare`) assert(mod === 'Hello from addon') diff --git a/test/import-addon.mjs b/test/import-addon.mjs index e13d060a..31798eba 100644 --- a/test/import-addon.mjs +++ b/test/import-addon.mjs @@ -1,6 +1,7 @@ +/* global Bare */ import assert from 'bare-assert' -import build from './helpers/build.json' +const { Addon } = Bare -const { default: mod } = await import(build.output.bare_addon) +const { default: mod } = await import(`./fixtures/addon/prebuilds/${Addon.host}/addon.bare`) assert(mod === 'Hello from addon')