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: make tests cwd-independent #12812

Closed

Conversation

@vsemozhetbyt
Copy link
Contributor

commented May 3, 2017

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test

Editing and checking various tests, I've sometimes stumbled on cases when tests failed depending on cwd. So I've run all the tests with this simple script to find out cwd-dependent tests. The script runs all tests from repo root (default test runner tools/test.py behavior) as well as from these ones: root/.., root/test, root/test/<test subdirectory>. If a test fails in all cases or in no cases, it is loosely considered cwd-independent.

So I've found out these 3 cwd-dependent tests:

  1. parallel/test-process-chdir.js can only be run outside of its directory (it makes too optimistic assumption that process.cwd() always !== __dirname after test start).
  2. doctool/test-doctool-html.js can only be run from the repo root.
  3. parallel/test-cli-eval.js can only be run from the repo root. It tests some murky old regression bug in the critical fragment, so I've tried to be extra careful there.

After this PR, these tests can be launched from any cwd.

@vsemozhetbyt

This comment has been minimized.

Copy link
Contributor Author

commented May 3, 2017

@aqrln
aqrln approved these changes May 3, 2017
@refack
refack approved these changes May 4, 2017
@cjihrig
cjihrig approved these changes May 4, 2017
@Trott
Trott approved these changes May 4, 2017
Copy link
Member

left a comment

LGTM if CI is green.

It might be over-engineering, but perhaps a way to guard against this coming up with future tests would be to to have the common module do a chdir() to the expected directory. I'm not actually sure how I feel about that...

@jasnell
jasnell approved these changes May 4, 2017
@addaleax

This comment has been minimized.

Copy link
Member

commented May 5, 2017

Landed in f1d593c

@addaleax addaleax closed this May 5, 2017

addaleax added a commit that referenced this pull request May 5, 2017
test: make tests cwd-independent
PR-URL: #12812
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

@vsemozhetbyt vsemozhetbyt deleted the vsemozhetbyt:tests-cwd-independent branch May 5, 2017

anchnk pushed a commit to anchnk/node that referenced this pull request May 6, 2017
test: make tests cwd-independent
PR-URL: nodejs#12812
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@vsemozhetbyt vsemozhetbyt referenced this pull request May 10, 2017
2 of 2 tasks complete
@jasnell jasnell referenced this pull request May 11, 2017
@gibfahn gibfahn referenced this pull request Jun 15, 2017
2 of 3 tasks complete
gibfahn added a commit that referenced this pull request Jun 18, 2017
test: make tests cwd-independent
PR-URL: #12812
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
gibfahn added a commit that referenced this pull request Jun 20, 2017
test: make tests cwd-independent
PR-URL: #12812
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
MylesBorins added a commit that referenced this pull request Jul 11, 2017
test: make tests cwd-independent
PR-URL: #12812
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@MylesBorins MylesBorins referenced this pull request Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.