-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Support defining test reporter using environment variable #46484
Comments
It's unlikely that we will add an environment variable for this. The general consensus is for things like that to be done via |
@cjihrig |
@MoLow sounds fine to me. The main reason for not doing so up to this point is that we'll need to parse the |
Re: the last couple of comments, I can dig into this if no one else is busy with it. |
The problem I see putting this in Another solution could be to introduce a Node user configuration file ( {
"repl": {
"ignoreUndefined": true
},
"test-reporter": [
"spec",
["tap", "output.tap"]
]
} |
I think the intuitive behavior would be to ignore the values in NODE_OPTIONS when flags are passed via the CLI. |
|
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS. Fixes nodejs#46484
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS. Fixes nodejs#46484
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS. Fixes: nodejs#46484
This mostly works but will break on a |
@SRHerzog why do we need to parse them again? Surely there must be a place in the codebase where the parsing is already done for us, and there are other options which support a space between the option name and the value, e.g. --require. |
NODE_OPTIONS is parsed in the C++ layer and merged with the CLI arguments, along with defaults where appropriate. It's read by the JavaScript layer as a Map after that merge is complete. There isn't a binding for the JavaScript runtime to retrieve NODE_OPTIONS in tokenized form or extract the NODE_OPTIONS values from the overall options map, so we would have to add that kind of functionality to |
Gotcha, I'm not familiar enough with the codebase to know when things happen exactly, I was just assuming that they must be happening somewhere. I assume that that when happens to late for us to make any use of it in this context. I wonder, aren't there other NODE_OPTIONS entries which the test runner is already making use of? How are they parsed? |
The only option specific to the test runner that can currently be passed through NODE_OPTIONS is |
Apologies Steve I'm just commenting without any good level of understanding of what's actually going on here. Why can't we do the same as with --test-only then? |
I think it's necessary for |
Ok this makes more sense now, thanks for clarifying. I'm not particularly fond of the solution but I don't have any better ideas. |
I agree that parsing and filtering the command line args and NODE_OPTIONS seems hacky. A cleaner implementation would be to add another option to pass to the child process that causes it to override the normal logic for identifying test reporters and destinations.
|
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS. Also adds the CLI flag --test-child-process to allow forcing the default test-reporter for inter-process communication. Fixes: nodejs#46484
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS. Also adds the CLI flag --test-child-process to allow forcing the default test-reporter for inter-process communication. Fixes: nodejs#46484
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS. Also adds the CLI flag --test-child-process to allow forcing the default test-reporter for inter-process communication. Fixes: #46484 PR-URL: #46688 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS. Also adds the CLI flag --test-child-process to allow forcing the default test-reporter for inter-process communication. Fixes: #46484 PR-URL: #46688 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS. Also adds the CLI flag --test-child-process to allow forcing the default test-reporter for inter-process communication. Fixes: #46484 PR-URL: #46688 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
What is the problem this feature will solve?
#45712 added support for custom test reporters, which is great!
It’s still a but cumbersome having to specify the
--test-reporter
flag for every test run.What is the feature you are proposing to solve the problem?
Use an environment variable
NODE_TEST_REPORTER
. If this is set, this will override the defaulttap
runner. The command line argument will still take precedence. If this is specified, it will entirely ignore theNODE_TEST_REPORTER
environment variable.This allows users to define their preferred formatter in their environment, e.g. in
~/.bashrc
or~/.zshrc
What alternatives have you considered?
It could also be supported in
NODE_OPTIONS
. However, people use this for different purposes too.The text was updated successfully, but these errors were encountered: