Skip to content

Commit

Permalink
Get addon tests running again
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Feb 16, 2024
1 parent f7c1116 commit 5074633
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 0 additions & 13 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions test/addon-load.js
Original file line number Diff line number Diff line change
@@ -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')
7 changes: 4 additions & 3 deletions test/addon-resolve.js
Original file line number Diff line number Diff line change
@@ -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'))
18 changes: 16 additions & 2 deletions test/fixtures/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 2 additions & 2 deletions test/fixtures/addon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
8 changes: 7 additions & 1 deletion test/fixtures/bundle/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
1 change: 0 additions & 1 deletion test/helpers/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions test/helpers/build.json.in

This file was deleted.

5 changes: 3 additions & 2 deletions test/import-addon.cjs
Original file line number Diff line number Diff line change
@@ -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')
5 changes: 3 additions & 2 deletions test/import-addon.mjs
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 5074633

Please sign in to comment.