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

[v8.x backport] tools, test: forbid string literal as third argument for assert.strictEqual() and friends #22888

Closed
wants to merge 6 commits into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Sep 17, 2018

Backport of #22849.

This backport does not preserve the lint rule (because it would result in 121 lint warnings in the v8.x code base), but preserves all the relevant changes to tests due to the lint rule.

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

Remove an unecessary string literal from assert.strictEqual() call in
test-inspector.js. The string literal is printed instead of the value
that causes an error. Removing the string literal allows the value that
caused the error to be printed. This improves the troubleshooting
experience when the test fails due to that assertion.

PR-URL: nodejs#22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
In test-http2-timeout-large-write.js and
test-http2-timeout-large-write-file.js:

Use assert.ok() on a boolean that the test itself creates and sets,
rather than assert.strictEqual(). This allows us to use a static message
without running afoul of the upcoming "do not use string literals with
assert.strictEqual()" lint rule.

PR-URL: nodejs#22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Refactor test-vm-run-in-new-context so that check for `--expose-gc` flag
will not run afoul of an upcoming lint rule that checks that string
literals are not used for the `message` argument of
`assert.strictEqual()`.

PR-URL: nodejs#22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Remove string literal from `assert.strictEqual()` call `message`
parameter and make it a comment above the assertion instead.

PR-URL: nodejs#22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Remove string literal as assertion message in call to
assert.strictEqual() in test-dns-resolveany-bad-ancount.

PR-URL: nodejs#22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Make minor modifications to test-assert.js to prepare it for linting
rule that forbids the use of string literals for the third argument of
assert.strictEqual().

PR-URL: nodejs#22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@Trott
Copy link
Member Author

Trott commented Sep 17, 2018

MylesBorins pushed a commit that referenced this pull request Sep 25, 2018
Remove an unecessary string literal from assert.strictEqual() call in
test-inspector.js. The string literal is printed instead of the value
that causes an error. Removing the string literal allows the value that
caused the error to be printed. This improves the troubleshooting
experience when the test fails due to that assertion.

Backport-PR-URL: #22888
PR-URL: #22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 25, 2018
In test-http2-timeout-large-write.js and
test-http2-timeout-large-write-file.js:

Use assert.ok() on a boolean that the test itself creates and sets,
rather than assert.strictEqual(). This allows us to use a static message
without running afoul of the upcoming "do not use string literals with
assert.strictEqual()" lint rule.

Backport-PR-URL: #22888
PR-URL: #22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 25, 2018
Refactor test-vm-run-in-new-context so that check for `--expose-gc` flag
will not run afoul of an upcoming lint rule that checks that string
literals are not used for the `message` argument of
`assert.strictEqual()`.

Backport-PR-URL: #22888
PR-URL: #22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 25, 2018
Remove string literal from `assert.strictEqual()` call `message`
parameter and make it a comment above the assertion instead.

Backport-PR-URL: #22888
PR-URL: #22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 25, 2018
Remove string literal as assertion message in call to
assert.strictEqual() in test-dns-resolveany-bad-ancount.

Backport-PR-URL: #22888
PR-URL: #22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 25, 2018
Make minor modifications to test-assert.js to prepare it for linting
rule that forbids the use of string literals for the third argument of
assert.strictEqual().

Backport-PR-URL: #22888
PR-URL: #22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@MylesBorins
Copy link
Contributor

landed in 0340dd8...8209ccb

@Trott Trott deleted the v8.x-backport-22849 branch January 13, 2022 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants