Commit graph

16 commits

Author SHA1 Message Date
Luke Karrys
4e493d4fb2
chore: misc testing fixes (#2930)
* chore: misc test fixes

* Sort test runs by os first

* Use cross-env for test env var

* Try sorting matrix params

* Make FAST_TEST the default and rename to FULL_TEST

* Separate helper functions to not need to export test obj in files
2023-10-28 14:13:10 -07:00
Luke Karrys
355622f4aa feat: convert all internal functions to async/await
BREAKING CHANGE: All internal functions have been coverted to return
promises and no longer accept callbacks. This is not a breaking change
for users but may be breaking to consumers of `node-gyp` if you are
requiring internal functions directly.
2023-10-28 08:59:57 -07:00
Tim Perry
0f1f667b73
fix: create Python symlink only during builds, and clean it up after (#2721)
* fix: create Python symlink only during builds, and clean it up after

Previously in b9ddcd5bbd this was created
during configuration, and the symlink persisted indefinitely. This
causes problems with many tools that do not expect a codebase to include
symlinks to external absolute paths.

This PR largely reverts that commit, and instead writes the path to
link to into the config, and then creates the symlink only temporarily
during the build process, always deleting it afterwards.

* assert install_path == self.output, f"{install_path} != {self.output}"

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-08-01 10:02:59 +02:00
Luke Karrys
192eec2aca
Sync deps and engines with npm (#2770)
* feat!: update `engines.node` to `^14.17.0 || ^16.13.0 || >=18.0.0`

* deps: nopt@^7.0.0

* feat: replace npmlog with proc-log

* deps: standard@17.0.0 and fix linting errors

* deps: which@3.0.0
- this also promiisifies the build command

* deps: glob@8.0.3

* feat: drop rimraf dependency

* fix: use fs/promises in favor of fs.promises
2023-06-20 15:44:18 +02:00
Stefan Stojanovic
5df2b72a8f
Migration from tap to mocha (#2851)
* migrate from tap to mocha

After make-fetch-happen update GitHub Actions started failing. Migrating
from tap to mocha testing framework for GitHub Action stability.

* write custom test reporter for more verbose output

Implemented a simple custom mocha test reporter to replace the default
one. Made test report more developer friendly.
2023-06-05 17:05:29 +02:00
DeeDeeG
b9ddcd5bbd
Add Python symlink to path (for non-Windows OSes only) (#2362)
* lib: create a Python symlink and add it to PATH

Helps to ensure a version of Python validated by lib/find-python.js
is used to run various Python scripts generated by gyp.

Known to affect gyp-mac-tool, probably affects gyp-flock-tool as well.

These Python scripts (such as `gyp-mac-tool`) are invoked directly,
via the generated Makefile, so their shebang lines determine
which Python binary is used to run them.
The shebang lines of these scripts are all `#!/usr/bin/env python3`,
so the first `python3` on the user's PATH will be used.

By adding a symlink to the Python binary validated by find-python.js,
and putting this symlink first on the PATH, we can ensure we use
a compatible version of Python to run these scripts.

(Only on Unix/Unix-like OSes. Symlinks are tricky on Windows,
and Python isn't used at build-time anyhow on Windows,
so this intervention isn't useful or necessary on Windows.

A similar technique for Windows, no symlinks required,
would be to make batch scripts which execute the target binary,
much like what Node does for its bundled copy of npm on Windows.)

* test: update mocked graceful-fs for configure test

Add missing functions "unlink()" and "symlink()" to mocked module.

* lib: log any errors when creating Python symlink

Warn users about errors, but continue on in case the user does
happen to have new enough Python on their PATH.

(The symlinks are only meant to fix an issue in a corner case,
where the user told `node-gyp` where new enough Python is,
but it's not the first `python3` on their PATH.
We should not introduce a new potential failure mode to all users
when fixing this bug. So no hard errors during the symlink process.)

* lib: improve error formatting for Python symlink

Logging the entire error object shows the stack twice,
and all the other information is contained in the stack.

It also messes with the order of what is logged.

Rather than logging a bunch of redundant information in a messy way,
we can log only the stack. Logging it in a separate log.warn()
also gets rid of an extra space character at the beginning of the line.

* lib: restore err.errno to logs for symlink errors

This info (err.errno) is the only piece of information
in the error object that is not redundant to err.stack.

* lib: use log.verbose, not log.warn

These messages aren't important enough to be `log.warn`s.

Log as verbose only; they will also appear in full error output.
2022-06-10 14:11:23 +02:00
Cheng Zhao
a27dc08696 feat: build with config.gypi from node headers 2021-11-05 20:08:28 +11:00
Rod Vagg
4937722cf5
deps: replace mkdirp with {recursive} mkdir
only supported on Node.js 10+

Closes: #2084
PR-URL: https://github.com/nodejs/node-gyp/pull/2123
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2020-06-03 12:56:39 +10:00
Rod Vagg
0670e5189d
test: add header download test
PR-URL: https://github.com/nodejs/node-gyp/pull/1796
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-11-18 13:31:15 +11:00
Rod Vagg
c506a6a150
test: configure proper devDir for invoking configure()
test/test-configure-python.js downloads a fresh set of headers to the
package directory each time. By setting to the default global cache dir
we get to re-use cached headers and skip the download step.

PR-URL: https://github.com/nodejs/node-gyp/pull/1796
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-11-18 13:30:35 +11:00
Rod Vagg
ab2a4cc209
src: update to standard@14
PR-URL: https://github.com/nodejs/node-gyp/pull/1899
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-10-02 13:57:30 +10:00
Rod Vagg
e40c99e283
src: implement standard.js linting
In addition:

* moved module.exports to the bottom
* no single-line if statements
* no if statements without a {
* const for requires
* array declarations get spaces inside [ ]
* 'use strict' in all .js files

PR-URL: https://github.com/nodejs/node-gyp/pull/1794
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-07-06 14:36:37 +10:00
Rod Vagg
a52c6eb9e8
test: migrate from tape to tap
PR-URL: https://github.com/nodejs/node-gyp/pull/1795
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-06-25 11:26:08 +10:00
Jon Moss
a5b7410497
Add ESLint no-unused-vars rule
- Uses `.eslintrc.yaml` for configuration
- `npm run lint` is part of `npm test`

PR-URL: https://github.com/nodejs/node-gyp/pull/1497
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
2019-04-24 10:27:29 +10:00
Richard Lau
a83a3801fc
test: fix test/test-configure-python on AIX
On AIX, lib/configure.js attempts to locate node.exp via calls to
fs.openSync() and fs.closeSync(). Add these functions to the mocked
`graceful-fs` object in test/test-configure-python.js.

PR-URL: https://github.com/nodejs/node-gyp/pull/1131
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-04-25 14:40:04 +01:00
Michael Hart
ddac348991 Use push on PYTHONPATH and add tests
Using push instead of the original unshift makes the logic a little
cleaner to read here.

PR-URL: https://github.com/nodejs/node-gyp/pull/990
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-10-07 10:38:25 +02:00