Skip to content

Commit

Permalink
Merge pull request #178 from jmartin4563/remove-loader
Browse files Browse the repository at this point in the history
refactor: gate usage of loader in versioned tests by NR_LOADER environment variable
  • Loading branch information
bizob2828 committed Aug 15, 2023
2 parents 0342e4d + 6bb7a2b commit 39472c0
Show file tree
Hide file tree
Showing 7 changed files with 852 additions and 806 deletions.
12 changes: 6 additions & 6 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ THE SOFTWARE.

### semver

This product includes source derived from [semver](https://github.com/npm/node-semver) ([v5.7.1](https://github.com/npm/node-semver/tree/v5.7.1)), distributed under the [ISC License](https://github.com/npm/node-semver/blob/v5.7.1/LICENSE):
This product includes source derived from [semver](https://github.com/npm/node-semver) ([v7.5.4](https://github.com/npm/node-semver/tree/v7.5.4)), distributed under the [ISC License](https://github.com/npm/node-semver/blob/v7.5.4/LICENSE):

```
The ISC License
Expand All @@ -308,7 +308,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

### @newrelic/eslint-config

This product includes source derived from [@newrelic/eslint-config](https://github.com/newrelic/eslint-config-newrelic) ([v0.0.3](https://github.com/newrelic/eslint-config-newrelic/tree/v0.0.3)), distributed under the [Apache-2.0 License](https://github.com/newrelic/eslint-config-newrelic/blob/v0.0.3/LICENSE):
This product includes source derived from [@newrelic/eslint-config](https://github.com/newrelic/eslint-config-newrelic) ([v0.3.0](https://github.com/newrelic/eslint-config-newrelic/tree/v0.3.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/eslint-config-newrelic/blob/v0.3.0/LICENSE):

```
Apache License
Expand Down Expand Up @@ -854,10 +854,10 @@ OTHER DEALINGS IN THE SOFTWARE.

### eslint

This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v7.32.0](https://github.com/eslint/eslint/tree/v7.32.0)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v7.32.0/LICENSE):
This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v8.43.0](https://github.com/eslint/eslint/tree/v8.43.0)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v8.43.0/LICENSE):

```
Copyright JS Foundation and other contributors, https://js.foundation
Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -1277,7 +1277,7 @@ This product includes source derived from [lockfile-lint](https://github.com/lir

### newrelic

This product includes source derived from [newrelic](https://github.com/newrelic/node-newrelic) ([v9.14.0](https://github.com/newrelic/node-newrelic/tree/v9.14.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic/blob/v9.14.0/LICENSE):
This product includes source derived from [newrelic](https://github.com/newrelic/node-newrelic) ([v10.6.2](https://github.com/newrelic/node-newrelic/tree/v10.6.2)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic/blob/v10.6.2/LICENSE):

```
Apache License
Expand Down Expand Up @@ -7498,7 +7498,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

### tap

This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v16.3.4](https://github.com/tapjs/node-tap/tree/v16.3.4)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v16.3.4/LICENSE):
This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v16.3.8](https://github.com/tapjs/node-tap/tree/v16.3.8)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v16.3.8/LICENSE):

```
The ISC License
Expand Down
2 changes: 1 addition & 1 deletion lib/versioned/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function runTests(cb) {
// TODO: Add tap arguments, such as color.
process.send({ status: 'running' })
let args = [testFile]
if (process.env.PKG_TYPE === 'module') {
if (process.env.PKG_TYPE === 'module' && process.env.NR_LOADER) {
const loaderPath = path.resolve(process.env.NR_LOADER)
const loaderArg = semver.lt(process.version, '18.0.0') ? '--experimental-loader' : '--loader'
args = [loaderArg, loaderPath, testFile]
Expand Down
9 changes: 2 additions & 7 deletions lib/versioned/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,10 @@ Test.prototype.run = function run() {
PKG_TYPE: this.type
}

if (this.type === 'module') {
if (this.type === 'module' && process.env.NR_LOADER) {
// The test loader is defined in the agent, so this uses process.cwd() instead of __directory.
const cwd = process.cwd()
let loaderPath = path.resolve(`${cwd}/test/lib/`, 'test-loader.mjs')
if (process.env.NR_LOADER) {
// Allow for override from environment
// This assumes that the loader path is defined in relation to the agent root.
loaderPath = path.resolve(cwd, process.env.NR_LOADER)
}
const loaderPath = path.resolve(cwd, process.env.NR_LOADER)
// changing env var for loader so subsequent commonjs
// runs that have NR_LOADER do not try to load it
additionalArgs.NR_LOADER = loaderPath
Expand Down
Loading

0 comments on commit 39472c0

Please sign in to comment.