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: making test-runner-run.mjs ignore colors #54552

Conversation

puskin94
Copy link
Contributor

Fixes: #54551

@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. test Issues and PRs related to the tests. labels Aug 25, 2024
@RedYetiDev
Copy link
Member

Hi! Could you amend your commit message to begin with an active verb? Something like test: ignore colors in `test-runner-run`

@puskin94 puskin94 force-pushed the test-make-test-runner-run-ignore-colors branch 2 times, most recently from d1ce27f to 1eee01c Compare August 25, 2024 15:39
@puskin94
Copy link
Contributor Author

Hi! Could you amend your commit message to begin with an active verb? Something like test: ignore colors in `test-runner-run`

done 😄

Copy link

codecov bot commented Aug 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.89%. Comparing base (26b03c1) to head (120d49b).
Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #54552      +/-   ##
==========================================
- Coverage   87.90%   87.89%   -0.01%     
==========================================
  Files         651      651              
  Lines      183364   183364              
  Branches    35719    35711       -8     
==========================================
- Hits       161182   161174       -8     
- Misses      15461    15465       +4     
- Partials     6721     6725       +4     

see 25 files with indirect coverage changes

@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 25, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 25, 2024
@nodejs-github-bot

This comment was marked as outdated.

@puskin94
Copy link
Contributor Author

puskin94 commented Aug 25, 2024

I guess this commit broke the tests I wrote just a couple of days ago and that now are in the main branch: 52322aa

Am I reading this wrong or that commit is actually causing an issue?

Why should I not be allowed to listen on ipv6_link_local which could be locally resolved to a valid IP ?

@RedYetiDev
Copy link
Member

See #54556

@jazelly
Copy link
Contributor

jazelly commented Aug 26, 2024

@puskin94 After looking at the previous implementation, server.listen accepts any string passed into dns.lookup. I started thinking introducing this enforcement might be too restricted. I think it's worth it to discuss more on this. I'll raise it to the original issue thread.

@puskin94
Copy link
Contributor Author

@puskin94 After looking at the previous implementation, server.listen accepts any string passed into dns.lookup. I started thinking introducing this enforcement might be too restricted. I think it's worth it to discuss more on this. I'll raise it to the original issue thread.

@jazelly exactly what I am thinking too. I should be allowed to have whatever_i_want in my /etc/hosts file and being able to listen to it, always imho 😄

@puskin94 puskin94 force-pushed the test-make-test-runner-run-ignore-colors branch 2 times, most recently from 1eee01c to fbff99f Compare August 26, 2024 06:50
@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 26, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 26, 2024
@nodejs-github-bot

This comment was marked as outdated.

@MoLow
Copy link
Member

MoLow commented Aug 26, 2024

This should land only if there are other tests that ensures colors work as expected

@puskin94 puskin94 force-pushed the test-make-test-runner-run-ignore-colors branch from fbff99f to 79e477d Compare August 27, 2024 07:05
@puskin94
Copy link
Contributor Author

This should land only if there are other tests that ensures colors work as expected

@MoLow went for a more elegant solution then :) just checking for the colors when in TTY

'\n',
]);

if (process.stderr.isTTY) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if instead of checking isTTY, you strip the problematic characters all the time.

Copy link
Contributor Author

@puskin94 puskin94 Aug 27, 2024

Choose a reason for hiding this comment

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

@cjihrig because is far as I understand we don't want to change the code implementation, we want to keep the colors and we just want to make the test ignore them.. or? am I misinterpreting this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant use util.stripVTControlCharacters() unconditionally in the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh! because I didn't know about its existence 😄 thanks!

@puskin94 puskin94 force-pushed the test-make-test-runner-run-ignore-colors branch from 79e477d to 3078f79 Compare August 27, 2024 14:19
@@ -4,6 +4,7 @@ import { join } from 'node:path';
import { describe, it, run } from 'node:test';
import { dot, spec, tap } from 'node:test/reporters';
import assert from 'node:assert';
import utils from 'internal/util/inspect';
Copy link
Member

Choose a reason for hiding this comment

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

I believe this needs the following at the top for the new internal import to work:

// Flags: --expose-internals

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I just figured it out, I should have read this comment earlier 😄 I thought it was there in other tests just as a reference, I didn't know it was actually functional...

Copy link
Contributor

Choose a reason for hiding this comment

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

You could also use the function exported from the public API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah even using the Flags comment didn't work, let's try with the public API this time

@puskin94 puskin94 force-pushed the test-make-test-runner-run-ignore-colors branch 2 times, most recently from 7d9ab97 to 09dd583 Compare August 27, 2024 17:03
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

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

Comment on lines +73 to +75
assert.strictEqual(result.length, 2);
assert.strictEqual(util.stripVTControlCharacters(result[0]), '.');
assert.strictEqual(result[1], '\n');
Copy link
Contributor

@aduh95 aduh95 Sep 6, 2024

Choose a reason for hiding this comment

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

nit: using deepStrictEqual makes for a much better DX if the test was to fail.

Suggested change
assert.strictEqual(result.length, 2);
assert.strictEqual(util.stripVTControlCharacters(result[0]), '.');
assert.strictEqual(result[1], '\n');
assert.deepStrictEqual(
result?.map?.((v, i) => i === 0 ? util.stripVTControlCharacters(v) : v),
['.', '\n'],
);

Copy link
Contributor Author

@puskin94 puskin94 Sep 6, 2024

Choose a reason for hiding this comment

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

@aduh95 I am 👎 on this. For 2 lines a loop is just overkill and introduces complexity and confusion IMHO

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@cjihrig
Copy link
Contributor

cjihrig commented Sep 10, 2024

It may be worth rebasing this to pick up some of the tests marked as flaky.

@puskin94 puskin94 force-pushed the test-make-test-runner-run-ignore-colors branch 2 times, most recently from f4e1232 to 21b839f Compare September 10, 2024 14:00
@puskin94 puskin94 force-pushed the test-make-test-runner-run-ignore-colors branch from 21b839f to 120d49b Compare September 10, 2024 14:05
@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 10, 2024
@github-actions github-actions bot added request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Sep 10, 2024
Copy link
Contributor

Failed to start CI
   ⚠  Something was pushed to the Pull Request branch since the last approving review.
   ℹ  request-ci label was added by a Collaborator after the last push event.
- Validating Jenkins credentials
✔  Jenkins credentials valid
- Starting PR CI job
✘  Failed to start PR CI: 400 Bad Request
https://github.com/nodejs/node/actions/runs/10797001710

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@cjihrig cjihrig removed needs-ci PRs that need a full CI run. request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. labels Sep 12, 2024
@cjihrig cjihrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Sep 12, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 12, 2024
@nodejs-github-bot nodejs-github-bot merged commit 92ca0b7 into nodejs:main Sep 12, 2024
59 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 92ca0b7

RafaelGSS pushed a commit that referenced this pull request Sep 16, 2024
Fixes: #54551
PR-URL: #54552
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@RafaelGSS RafaelGSS mentioned this pull request Sep 16, 2024
RafaelGSS pushed a commit that referenced this pull request Sep 16, 2024
Fixes: #54551
PR-URL: #54552
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Sep 17, 2024
Fixes: #54551
PR-URL: #54552
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
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. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test test/parallel/test-runner-run.mjs fails when run from a TTY with color support
10 participants