test: use fixture directories for sea tests · nodejs/node@cabd58f · GitHub
Skip to content

Commit cabd58f

Browse files
joyeecheungaduh95
authored andcommitted
test: use fixture directories for sea tests
Instead of copying and writing files on the fly for SEA tests, put the fixtures into a directory and copy them into tmpdir for testing. This allows easier reproduction and debugging when they do fail - we can just copy the entire fixture directory and test directly from there. PR-URL: #61167 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 24033ee commit cabd58f

73 files changed

Lines changed: 649 additions & 727 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

test/common/sea.js

Lines changed: 50 additions & 8 deletions
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"main": "sea.js",
3+
"output": "sea-prep.blob",
4+
"disableExperimentalSEAWarning": true,
5+
"assets": {
6+
"hello.node": "binding.node"
7+
}
8+
}

test/fixtures/sea/addon/sea.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const sea = require('node:sea');
2+
const fs = require('fs');
3+
const path = require('path');
4+
5+
const addonPath = path.join(process.cwd(), 'hello.node');
6+
fs.writeFileSync(addonPath, new Uint8Array(sea.getRawAsset('hello.node')));
7+
const mod = {exports: {}};
8+
process.dlopen(mod, addonPath);
9+
console.log('hello,', mod.exports.hello());
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"main": "sea.js",
3+
"output": "sea-prep.blob"
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is asset 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is asset 2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is asset 3
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"main": "sea.js",
3+
"output": "sea-prep.blob",
4+
"assets": {
5+
"asset-1.txt": "asset-1.txt",
6+
"asset-2.txt": "asset-2.txt",
7+
"asset-3.txt": "asset-3.txt"
8+
}
9+
}
Lines changed: 9 additions & 0 deletions

0 commit comments

Comments
 (0)