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

doc,test: test documentation consistency for NODE_OPTIONS #28179

Closed
wants to merge 2 commits into from

Conversation

richardlau
Copy link
Member

@richardlau richardlau commented Jun 11, 2019

  • doc: add missing options allowed in NODE_OPTIONS
    Add missing options to the list of allowed options for the
    NODE_OPTIONS environment variable. Sort the list alphabetically.

  • doc,test: test documentation consistency for NODE_OPTIONS
    Add a test that checks that the documented allowed options for the
    NODE_OPTIONS environment variable are consistent with the actually
    allowed options.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@richardlau richardlau added the wip Issues and PRs that are still a work in progress. label Jun 11, 2019
@richardlau
Copy link
Member Author

This is a draft/wip because it currently (legitimately) fails:

-bash-4.2$ ./node test/parallel/test-process-env-allowed-flags-are-documented.js
assert.js:89
  throw new AssertionError(obj);
  ^

AssertionError [ERR_ASSERTION]: The following options are not documented as allowed in NODE_OPTIONS in /home/users/riclau/sandbox/github/nodejs/doc/api/cli.md: --tls-min-v1.2 --input-type --experimental-worker --tls-min-v1.3 --debug-arraybuffer-allocations --tls-max-v1.2 --experimental-policy --preserve-symlinks --http-parser --tls-min-v1.0 --es-module-specifier-resolution --preserve-symlinks-main --tls-max-v1.3 --tls-min-v1.1 --prof-process -r --debug-port
    at Object.<anonymous> (/home/users/riclau/sandbox/github/nodejs/test/parallel/test-process-env-allowed-flags-are-documented.js:35:8)
    at Module._compile (internal/modules/cjs/loader.js:777:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10)
    at Module.load (internal/modules/cjs/loader.js:640:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:840:10)
    at internal/main/run_main_module.js:17:11 {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: 17,
  expected: 0,
  operator: 'strictEqual'
}
-bash-4.2$

#28146 will fix the missing tls options. I'll add the other missing entries to the docs. If anyone sees anything in this list that shouldn't be there please say so.

@richardlau

This comment has been minimized.

@richardlau richardlau added doc Issues and PRs related to the documentations. test Issues and PRs related to the tests. labels Jun 11, 2019
@richardlau richardlau removed the wip Issues and PRs that are still a work in progress. label Jun 12, 2019
@richardlau richardlau marked this pull request as ready for review June 12, 2019 01:47
doc/api/cli.md Outdated Show resolved Hide resolved
const docsDir = path.resolve(__dirname, '..', '..', 'doc');
const cliMd = path.join(docsDir, 'api', 'cli.md');
const cliDocs = fs.readFileSync(cliMd, { encoding: 'utf8' });
const docRegExp = /^Node\.js options that are allowed are:$([^#]+)/m;
Copy link
Member

Choose a reason for hiding this comment

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

This seems brittle. A line-wrap change could break it. And I'll definitely break it when I inevitably decide to reduce passive voice from the doc. But I don't have a better idea, so...¯\(ツ)/¯ (FWIW, I'd prefer if the doc said something like "Valid options are:". But obviously that can and likely should be some other PR some time.)

Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW if we change the line in doc/api/cli.md to Valid options are: the test fails:

-bash-4.2$ ./node test/parallel/test-process-env-allowed-flags-are-documented.js
/home/users/riclau/sandbox/github/nodejs/test/parallel/test-process-env-allowed-flags-are-documented.js:17
const docOptions = cliDocs.match(docRegExp)[0];
                                           ^

TypeError: Cannot read property '0' of null
    at Object.<anonymous> (/home/users/riclau/sandbox/github/nodejs/test/parallel/test-process-env-allowed-flags-are-documented.js:17:44)
    at Module._compile (internal/modules/cjs/loader.js:779:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:790:10)
    at Module.load (internal/modules/cjs/loader.js:642:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:842:10)
    at internal/main/run_main_module.js:17:11
-bash-4.2$

I'll see what we can do to make this better.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Trott Changed this so that it now starts at the section header, which is less likely to change. PTAL.

(Test now still works when the prose is changed to "Valid options are:" but I'll let you make that change.)

Copy link
Member

Choose a reason for hiding this comment

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

Since HTML comments are valid Markdown, maybe we can delineate the list with a self-documenting HTML comment and use a RegExp to search for that? A suggestion, but totally not blocking this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added HTML comment markers. PTAL.

Of course now we have markers the follow on step would be to automatically update the list (since Node.js know which options are allowed in the environment and we've marked in the document where the lists should go). I'd prefer that to be a follow on PR 😁.

@BridgeAR
Copy link
Member

One more thought: we might also validate the correct documentation order.

@richardlau

This comment has been minimized.

Add missing options to the list of allowed options for the
`NODE_OPTIONS` environment variable. Sort the list alphabetically.
Add a test that checks that the documented allowed options for the
`NODE_OPTIONS` environment variable are consistent with the actually
allowed options.
@richardlau
Copy link
Member Author

One more thought: we might also validate the correct documentation order.

Validate the options are sorted? Maybe as a follow up PR -- at the moment some options are listed with their aliases (e.g. --require, -r and --inspect-port, --debug-port) plus there are two lists (the Node.js options and V8 options) which means it's not quite as straightforward as it might seem at first.

@BridgeAR After changing the test and documentation to use markers to denote where to parse the options from the documentation this ended up being much easier so I've updated the test to check the options are alphabetically sorted.

@richardlau
Copy link
Member Author

@jasnell
Copy link
Member

jasnell commented Jun 14, 2019

A lint rule might be better?

@richardlau
Copy link
Member Author

A lint rule might be better?

The node binary running the linter may not be the same as the one corresponding to the source tree. However I won't stand in the way if anyone else wants to attempt this as a lint rule.

@Trott
Copy link
Member

Trott commented Jun 15, 2019

Landed in 3cdd5a2...5225586

@Trott Trott closed this Jun 15, 2019
Trott pushed a commit to Trott/io.js that referenced this pull request Jun 15, 2019
Add missing options to the list of allowed options for the
`NODE_OPTIONS` environment variable. Sort the list alphabetically.

PR-URL: nodejs#28179
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Trott pushed a commit to Trott/io.js that referenced this pull request Jun 15, 2019
Add a test that checks that the documented allowed options for the
`NODE_OPTIONS` environment variable are consistent with the actually
allowed options.

PR-URL: nodejs#28179
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
BridgeAR pushed a commit that referenced this pull request Jun 17, 2019
Add missing options to the list of allowed options for the
`NODE_OPTIONS` environment variable. Sort the list alphabetically.

PR-URL: #28179
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
BridgeAR pushed a commit that referenced this pull request Jun 17, 2019
Add a test that checks that the documented allowed options for the
`NODE_OPTIONS` environment variable are consistent with the actually
allowed options.

PR-URL: #28179
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@BridgeAR BridgeAR mentioned this pull request Jun 17, 2019
targos pushed a commit that referenced this pull request Jun 18, 2019
Add missing options to the list of allowed options for the
`NODE_OPTIONS` environment variable. Sort the list alphabetically.

PR-URL: #28179
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
targos pushed a commit that referenced this pull request Jun 18, 2019
Add a test that checks that the documented allowed options for the
`NODE_OPTIONS` environment variable are consistent with the actually
allowed options.

PR-URL: #28179
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants