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

test_runner: skip --require for test orchestration process #52099

Closed
wants to merge 3 commits into from

Conversation

MoLow
Copy link
Member

@MoLow MoLow commented Mar 15, 2024

Fixes #48467

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. labels Mar 15, 2024
@MoLow
Copy link
Member Author

MoLow commented Mar 15, 2024

Watch mode already has such tests in place and dosen't need this condition since it passes initializeModules=false to

function prepareMainThreadExecution(expandArgv1 = false, initializeModules = true) {

test runner must pass initializeModules=true for reporters to work

it('should load --require modules in the watched process, and not in the orchestrator process', async () => {
const file = createTmpFile();
const required = createTmpFile('process._rawDebug(\'pid\', process.pid);');
const args = ['--require', required, file];
const { stdout, pid } = await runWriteSucceed({ file, watchedFile: file, args });
const importPid = parseInt(stdout[0].split(' ')[1], 10);
assert.notStrictEqual(pid, importPid);
assert.deepStrictEqual(stdout, [
'running',
`Completed running ${inspect(file)}`,
`Restarting ${inspect(file)}`,
'running',
`Completed running ${inspect(file)}`,
]);
});
it('should load --import modules in the watched process, and not in the orchestrator process', async () => {
const file = createTmpFile();
const imported = "data:text/javascript,process._rawDebug('pid', process.pid);";
const args = ['--import', imported, file];
const { stdout, pid } = await runWriteSucceed({ file, watchedFile: file, args });
const importPid = parseInt(stdout[0].split(' ')[1], 10);
assert.notStrictEqual(pid, importPid);
assert.deepStrictEqual(stdout, [
'running',
`Completed running ${inspect(file)}`,
`Restarting ${inspect(file)}`,
'running',
`Completed running ${inspect(file)}`,
]);
});

@MoLow MoLow force-pushed the test-runner-require branch 2 times, most recently from 0fc431e to ee77010 Compare March 15, 2024 13:40
test/parallel/test-runner-cli.js Show resolved Hide resolved
lib/internal/process/pre_execution.js Outdated Show resolved Hide resolved
@rluvaton
Copy link
Member

Wouldn't it break the following

node --require ts-node/register --test-reporter=ts-reporter.ts --test test.js

Not near computer so can't verify at the moment

@MoLow
Copy link
Member Author

MoLow commented Mar 17, 2024

Wouldn't it break the following

node --require ts-node/register --test-reporter=ts-reporter.ts --test test.js

Not near computer so can't verify at the moment

It will. I think the usecase of typescript reporters is less common than the issues reported by #48467 - and it can still be solved with --loader

@rluvaton
Copy link
Member

rluvaton commented Mar 17, 2024

Yes but it means that this is a breaking change

Adding label but if you think differently we can discuss

@rluvaton rluvaton added the semver-major PRs that contain breaking changes and should be released in the next major version. label Mar 17, 2024
@MoLow MoLow added the test_runner Issues and PRs related to the test runner subsystem. label Mar 17, 2024
@MoLow MoLow added the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label Apr 1, 2024
@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 1, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 1, 2024
@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 1, 2024
@MoLow
Copy link
Member Author

MoLow commented Apr 1, 2024

I need another @nodejs/tsc approval since this is marked as semver-major. PTAL

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 1, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 1, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 1, 2024
Copy link
Member

@GeoffreyBooth GeoffreyBooth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will. I think the usecase of typescript reporters is less common than the issues reported by #48467 - and it can still be solved with --loader

--loader is experimental and de facto deprecated in favor of --import. Before this lands, can someone please confirm that the following works (note that both the reporter and the test are TypeScript files):

node --import ts-node/register --test-reporter=ts-reporter.ts --test test.ts

And add a test to that effect? If not, this shouldn’t land as it replaces one bug with another.

Also if the above command works but changing --import to --require causes it to break, well, that’s another bug. I’m not sure if it’s worse than the bug that this PR is aiming to fix, so I’m not sure it’s worth blocking on that point since the remediation would be to use --import, but it’s not like we document that --require always works except when used with --test.

@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 1, 2024
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/52099
✔  Done loading data for nodejs/node/pull/52099
----------------------------------- PR info ------------------------------------
Title      test_runner: skip `--require` for test orchestration process (#52099)
Author     Moshe Atlow  (@MoLow)
Branch     MoLow:test-runner-require -> nodejs:main
Labels     semver-major, process, author ready, needs-ci, commit-queue-squash, test_runner
Commits    3
 - test_runner: skip `--require` for test orchestration process
 - CR
 - fixup! CR
Committers 1
 - Moshe Atlow 
PR-URL: https://github.com/nodejs/node/pull/52099
Reviewed-By: Colin Ihrig 
Reviewed-By: Chemi Atlow 
Reviewed-By: Matteo Collina 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/52099
Reviewed-By: Colin Ihrig 
Reviewed-By: Chemi Atlow 
Reviewed-By: Matteo Collina 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Fri, 15 Mar 2024 13:37:00 GMT
   ✘  Requested Changes: 1
   ✘  - Geoffrey Booth (@GeoffreyBooth) (TSC): https://github.com/nodejs/node/pull/52099#pullrequestreview-1972231968
   ✔  Approvals: 3
   ✔  - Colin Ihrig (@cjihrig): https://github.com/nodejs/node/pull/52099#pullrequestreview-1971512653
   ✔  - Chemi Atlow (@atlowChemi): https://github.com/nodejs/node/pull/52099#pullrequestreview-1972004444
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/52099#pullrequestreview-1971723293
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2024-04-01T20:33:31Z: https://ci.nodejs.org/job/node-test-pull-request/58041/
- Querying data for job/node-test-pull-request/58041/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/8514547329

@nodejs-github-bot nodejs-github-bot added the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Apr 1, 2024
@MoLow
Copy link
Member Author

MoLow commented Apr 2, 2024

that is a good point. makes me rethink about #48467 (comment)

I can't think of a good reason why preloads need to run for the main process.

registering a module hook/loader is one reason.

any thoughts on a better solution for #48467? thing is a lot of IDE's inject code to connect the debugger which breaks here

@GeoffreyBooth
Copy link
Member

I don't know. I'm dealing with a similar problem in #52242.

@MoLow MoLow closed this May 24, 2024
@MoLow MoLow deleted the test-runner-require branch May 24, 2024 09:01
@MoLow MoLow restored the test-runner-require branch May 24, 2024 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

V8 Inspector is not available in --require in node --test
8 participants