Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): improve tests and add DEVELOPMENT.md docs #111

Merged
merged 24 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c7b4bfb
docs: add DEVELOPMENT.md docs
robertsLando Oct 22, 2024
53aff7d
docs: add pre-build step
robertsLando Oct 22, 2024
93ed057
fix: enable node 20 tests
robertsLando Oct 23, 2024
e1d6518
refactor: create tests util `getNodeMajorVersion`
robertsLando Oct 23, 2024
0853a5c
refactor: clarify test utils methods
robertsLando Oct 23, 2024
9cf2155
fix: typo on utils
robertsLando Oct 23, 2024
9fb19b6
fix: test-50-fs-runtime-layer-3 broken on node 20 and above
robertsLando Oct 23, 2024
06940ea
fix: make `test-42-fetch-all` work again
robertsLando Oct 23, 2024
79ea781
fix: add fetch test for macos arm64
robertsLando Oct 23, 2024
abc6aa5
fix: test-46-multi-arch
robertsLando Oct 23, 2024
28aedb0
fix: skip npm tests
robertsLando Oct 23, 2024
1529aee
fix: error path on win
robertsLando Oct 23, 2024
55aea61
refactor: add comments to sea config props
robertsLando Oct 23, 2024
31bb11f
fix: windows error path
robertsLando Oct 23, 2024
be91e0b
fix: add code sign to sea macos
robertsLando Oct 23, 2024
00c7c99
chore: run host tests first
robertsLando Oct 23, 2024
10ca6d6
fix: sea test on windows and mac
robertsLando Oct 23, 2024
01d3eb7
fix: skip sea run on macos
robertsLando Oct 23, 2024
b737700
fix: disable sea run on win
robertsLando Oct 23, 2024
8c6448e
fix: sea error on remove
robertsLando Oct 23, 2024
eea9913
fix: don't throw when cleanup fails
robertsLando Oct 23, 2024
6abed7f
chore: add host info when running tests
robertsLando Oct 23, 2024
5d656d1
chore: disable sea output test on windows
robertsLando Oct 23, 2024
7ccd585
docs: add docs example
robertsLando Oct 23, 2024
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
44 changes: 44 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# PKG Development

This document aims to help you get started with `pkg` developemnt.

## Release Process

In order to create release just run the command:

```bash
npm run release
```

This command will start an interactive process that will guide you through the release process using [release-it](https://github.com/release-it/release-it)

## Testing

Before running tests ensure you have build the project by running:

```bash
npm run build
```

> [!NOTE]
> Remember to run again `npm run build` after changing the code.

Than you can use the following command to run tests:

```bash
node test/test.js <target> [no-npm | only-npm | all] [<flavor>]
```

- `<target>` is the node target the test will use when creating executables, can be `nodeXX` (like `node20`) or `host` (use host node version as target).
- `[no-npm | only-npm | all]` to specify which tests to run. `no-npm` will run tests that don't require npm, `only-npm` will run against some specific npm modules, and `all` will run all tests.
- `<flavor>` to use when you want to test matching a specific pattern. Example: `node test/test.js all test-99-*`. You can also set this by using `FLAVOR` environment variable.

Each test is located inside `test` directory into a dedicated folder named following the pattern `test-XX-*`. The `XX` is a number that represents the order the tests will run.

When running `node test/test.js all`, based on the options, each test will be run consecutively by running `main.js` file inside the test folder.

### Special tests

- `test-79-npm`: It's the only test runned when using `only-npm`. It install and tests all node modules listed inside that dir and verifies if they are working correctly.
- `test-42-fetch-all`: Foreach known node version verifies there is a patch existing for it using pkg-fetch.
- `test-46-multi-arch`: Tries to cross-compile a binary for all known architectures.
9 changes: 1 addition & 8 deletions test/test-42-fetch-all/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ function nodeRangeToNodeVersion(nodeRange) {
}

for (const platform of knownPlatforms) {
const nodeRanges = [
'node8',
'node10',
'node12',
'node14',
'node16',
'node18',
];
const nodeRanges = ['node16', 'node18', 'node20', 'node22'];
for (const nodeRange of nodeRanges) {
const nodeVersion = nodeRangeToNodeVersion(nodeRange);
const archs = ['x64'];
Expand Down
1 change: 1 addition & 0 deletions test/test-79-npm/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const npm = {
16: 7,
18: 8,
20: 10,
22: 10,
}[hostVersion];

assert(npm !== undefined);
Expand Down
6 changes: 6 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ if (flavor.match(/^test/)) {
ignore.push(joinAndForward('test-46-multi-arch'));
ignore.push(joinAndForward('test-46-multi-arch-2'));
ignore.push(joinAndForward('test-79-npm'));
ignore.push(joinAndForward('test-10-pnpm'));
ignore.push(joinAndForward('test-11-pnpm'));
ignore.push(joinAndForward('test-80-compression-node-opcua'));
ignore.push(joinAndForward('test-99-#1135'));
ignore.push(joinAndForward('test-99-#1191'));
ignore.push(joinAndForward('test-99-#1192'));
}
}

Expand Down
Loading