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: refactor common.ddCommand() #23411

Closed
wants to merge 6 commits into from
Closed

test: refactor common.ddCommand() #23411

wants to merge 6 commits into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Oct 10, 2018

  • Remove different paths for Windows and POSIX.
  • Remove fixtures file. Simply run the command immediately/directly.
  • Since it is never called with more than one value for kilobytes,
    eliminate that argument.
  • Update/simplify tests that use this function. (They no longer need to
    use child_process to run the command.)
  • Update documentation.
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 different paths for Windows and POSIX.
* Remove fixtures file. Simply run the command immediately/directly.
* Since it is never called with more than one value for kilobytes,
  eliminate that argument.
* Update/simplify tests that use this function. (They no longer need to
  use child_process to run the command.)
* Update documentation.
@Trott Trott added the test Issues and PRs related to the tests. label Oct 10, 2018
@Trott
Copy link
Member Author

Trott commented Oct 10, 2018

} else {
return `dd if=/dev/zero of="${filename}" bs=1024 count=${kilobytes}`;
}
function ddCommand(filename) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Then why not call it createZeroFilledFile?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because I'm lazy?

Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

1 nit


Platform normalizes the `dd` command
Creates a 10Mb file of all null characters.
Copy link
Contributor

Choose a reason for hiding this comment

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

Mb -> MB to not be confused with megabit?

}
function ddCommand(filename) {
const fd = fs.openSync(filename, 'w');
fs.ftruncateSync(fd, 10240 * 1024);
Copy link
Member

Choose a reason for hiding this comment

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

I think this should either be 10 * 1024 * 1024 (my preference) or 10485760.

@richardlau
Copy link
Member

Two failures across the board:

test-fs-error-messages

The removed fixture is also referenced in

const existingFile2 = fixtures.path('create-file.js');

https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel72-s390x/6012/console

14:31:01 not ok 551 parallel/test-fs-error-messages
14:31:01   ---
14:31:01   duration_ms: 0.157
14:31:01   severity: fail
14:31:01   exitcode: 1
14:31:01   stack: |-
14:31:01     assert.js:86
14:31:01       throw new AssertionError(obj);
14:31:01       ^
14:31:01     
14:31:01     AssertionError [ERR_ASSERTION]: Missing expected exception (validateError).
14:31:01         at Object.<anonymous> (/data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/parallel/test-fs-error-messages.js:228:10)
14:31:01         at Module._compile (internal/modules/cjs/loader.js:706:30)
14:31:01         at Object.Module._extensions..js (internal/modules/cjs/loader.js:717:10)
14:31:01         at Module.load (internal/modules/cjs/loader.js:604:32)
14:31:01         at tryModuleLoad (internal/modules/cjs/loader.js:543:12)
14:31:01         at Function.Module._load (internal/modules/cjs/loader.js:535:3)
14:31:01         at Function.Module.runMain (internal/modules/cjs/loader.js:759:12)
14:31:01         at startup (internal/bootstrap/node.js:303:19)
14:31:01         at bootstrapNodeJSCore (internal/bootstrap/node.js:866:3)

https://ci.nodejs.org/job/node-test-commit-osx/nodes=osx1011/21794/console

14:42:27 not ok 609 parallel/test-fs-error-messages
14:42:27   ---
14:42:27   duration_ms: 0.184
14:42:27   severity: fail
14:42:27   exitcode: 1
14:42:27   stack: |-
14:42:27     (node:42232) internal/test/binding: These APIs are exposed only for testing and are not tracked by any versioning system or deprecation process.
14:42:27     /Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1011/test/parallel/test-fs-error-messages.js:214
14:42:27         assert.strictEqual(existingFile, err.path);
14:42:27                                              ^
14:42:27     
14:42:27     TypeError: Cannot read property 'path' of null
14:42:27         at validateError (/Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1011/test/parallel/test-fs-error-messages.js:214:42)
14:42:27         at /Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1011/test/common/index.js:345:15
14:42:27         at FSReqCallback.oncomplete (fs.js:148:20)
test-module-loading

This PR makes test/common/index.js no longer require fixtures:
https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel72-s390x/6012/console

14:35:28 not ok 2386 sequential/test-module-loading
14:35:28   ---
14:35:28   duration_ms: 0.263
14:35:28   severity: fail
14:35:28   exitcode: 1
14:35:28   stack: |-
14:35:28     { loaded: 'from child' }
14:35:28     { loaded: 'from child' }
14:35:28     b/c.js exit
14:35:28     load test-module-loading.js
14:35:28     load fixtures/b/d.js
14:35:28     load package/index.js
14:35:28     load fixtures/b/c.js
14:35:28     load fixtures/a.js
14:35:28     test index.js modules ids and relative loading
14:35:28     test index.js in a folder with a trailing slash
14:35:28     test cycles containing a .. path
14:35:28     test node_modules folders
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/fixtures/node_modules/foo.js
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/fixtures/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/node_modules
14:35:28     /data/iojs/build/workspace/node_modules
14:35:28     /data/iojs/build/node_modules
14:35:28     /data/iojs/node_modules
14:35:28     /data/node_modules
14:35:28     /node_modules
14:35:28     
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/fixtures/node_modules/baz/index.js
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/fixtures/node_modules/baz/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/fixtures/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/node_modules
14:35:28     /data/iojs/build/workspace/node_modules
14:35:28     /data/iojs/build/node_modules
14:35:28     /data/iojs/node_modules
14:35:28     /data/node_modules
14:35:28     /node_modules
14:35:28     
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/fixtures/node_modules/bar.js
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/fixtures/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/node_modules
14:35:28     /data/iojs/build/workspace/node_modules
14:35:28     /data/iojs/build/node_modules
14:35:28     /data/iojs/node_modules
14:35:28     /data/node_modules
14:35:28     /node_modules
14:35:28     
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/fixtures/node_modules/baz/node_modules/asdf.js
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/fixtures/node_modules/baz/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/fixtures/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/nodes/node_modules
14:35:28     /data/iojs/build/workspace/node-test-commit-linuxone/node_modules
14:35:28     /data/iojs/build/workspace/node_modules
14:35:28     /data/iojs/build/node_modules
14:35:28     /data/iojs/node_modules
14:35:28     /data/node_modules
14:35:28     /node_modules
14:35:28     
14:35:28     test name clashes
14:35:28     load custom file types with extensions
14:35:28     load custom file types that return non-strings
14:35:28     load order
14:35:28     assert.js:86
14:35:28       throw new AssertionError(obj);
14:35:28       ^
14:35:28     
14:35:28     AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
14:35:28     + actual - expected ... Lines skipped
14:35:28     
14:35:28       {
14:35:28         'common/index.js': {
14:35:28     -     'common/fixtures.js': {},
14:35:28           'common/tmpdir.js': {}
14:35:28     ...
14:35:28         'fixtures/throws_error.js': {}
14:35:28       }
14:35:28         at Object.<anonymous> (/data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/sequential/test-module-loading.js:252:10)
14:35:28         at Module._compile (internal/modules/cjs/loader.js:706:30)
14:35:28         at Object.Module._extensions..js (internal/modules/cjs/loader.js:717:10)
14:35:28         at Module.load (internal/modules/cjs/loader.js:604:32)
14:35:28         at tryModuleLoad (internal/modules/cjs/loader.js:543:12)
14:35:28         at Function.Module._load (internal/modules/cjs/loader.js:535:3)
14:35:28         at Function.Module.runMain (internal/modules/cjs/loader.js:759:12)
14:35:28         at startup (internal/bootstrap/node.js:303:19)
14:35:28         at bootstrapNodeJSCore (internal/bootstrap/node.js:866:3)

Copy link
Member

@richardlau richardlau left a comment

Choose a reason for hiding this comment

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

@Trott
Copy link
Member Author

Trott commented Oct 10, 2018

Ugh! At least one of those tests writes to the fixtures directory. 😞

@Trott
Copy link
Member Author

Trott commented Oct 10, 2018

Fixed all nits, and (I think) fixed the test problems.

CI: https://ci.nodejs.org/job/node-test-pull-request/17729/

Change common.ddCommand() to common.createZeroFilledFile().
@Trott
Copy link
Member Author

Trott commented Oct 10, 2018

Whoops, missed a nit. Now I think I got all the nits.

CI: https://ci.nodejs.org/job/node-test-pull-request/17730/

@Trott
Copy link
Member Author

Trott commented Oct 10, 2018

CI: https://ci.nodejs.org/job/node-test-pull-request/17731/ ✔️

(Thanks, @refack!)

@Trott
Copy link
Member Author

Trott commented Oct 10, 2018

CI is green. Does this look good to you now, @richardlau?

@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 10, 2018
Trott added a commit to Trott/io.js that referenced this pull request Oct 12, 2018
* Remove different paths for Windows and POSIX.
* Remove fixtures file. Simply run the command immediately/directly.
* Since it is never called with more than one value for kilobytes,
  eliminate that argument.
* Update/simplify tests that use this function. (They no longer need to
  use child_process to run the command.)
* Update documentation.

PR-URL: nodejs#23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
Trott added a commit to Trott/io.js that referenced this pull request Oct 12, 2018
Change common.ddCommand() to common.createZeroFilledFile().

PR-URL: nodejs#23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
@Trott
Copy link
Member Author

Trott commented Oct 12, 2018

Landed in bcbb937...3d62d38

@Trott Trott closed this Oct 12, 2018
@addaleax
Copy link
Member

Should this be backported to v10.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

@Trott
Copy link
Member Author

Trott commented Oct 12, 2018

@addaleax Backport in #23630

Trott added a commit to Trott/io.js that referenced this pull request Oct 13, 2018
* Remove different paths for Windows and POSIX.
* Remove fixtures file. Simply run the command immediately/directly.
* Since it is never called with more than one value for kilobytes,
  eliminate that argument.
* Update/simplify tests that use this function. (They no longer need to
  use child_process to run the command.)
* Update documentation.

PR-URL: nodejs#23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
Trott added a commit to Trott/io.js that referenced this pull request Oct 13, 2018
Change common.ddCommand() to common.createZeroFilledFile().

PR-URL: nodejs#23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
targos pushed a commit that referenced this pull request Oct 13, 2018
* Remove different paths for Windows and POSIX.
* Remove fixtures file. Simply run the command immediately/directly.
* Since it is never called with more than one value for kilobytes,
  eliminate that argument.
* Update/simplify tests that use this function. (They no longer need to
  use child_process to run the command.)
* Update documentation.

Backport-PR-URL: #23630
PR-URL: #23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
targos pushed a commit that referenced this pull request Oct 13, 2018
Change common.ddCommand() to common.createZeroFilledFile().

Backport-PR-URL: #23630
PR-URL: #23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
jasnell pushed a commit that referenced this pull request Oct 17, 2018
* Remove different paths for Windows and POSIX.
* Remove fixtures file. Simply run the command immediately/directly.
* Since it is never called with more than one value for kilobytes,
  eliminate that argument.
* Update/simplify tests that use this function. (They no longer need to
  use child_process to run the command.)
* Update documentation.

PR-URL: #23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
jasnell pushed a commit that referenced this pull request Oct 17, 2018
Change common.ddCommand() to common.createZeroFilledFile().

PR-URL: #23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
MylesBorins pushed a commit that referenced this pull request Oct 30, 2018
* Remove different paths for Windows and POSIX.
* Remove fixtures file. Simply run the command immediately/directly.
* Since it is never called with more than one value for kilobytes,
  eliminate that argument.
* Update/simplify tests that use this function. (They no longer need to
  use child_process to run the command.)
* Update documentation.

Backport-PR-URL: #23630
PR-URL: #23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
MylesBorins pushed a commit that referenced this pull request Oct 30, 2018
Change common.ddCommand() to common.createZeroFilledFile().

Backport-PR-URL: #23630
PR-URL: #23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
@codebytere codebytere mentioned this pull request Nov 27, 2018
rvagg pushed a commit that referenced this pull request Nov 28, 2018
* Remove different paths for Windows and POSIX.
* Remove fixtures file. Simply run the command immediately/directly.
* Since it is never called with more than one value for kilobytes,
  eliminate that argument.
* Update/simplify tests that use this function. (They no longer need to
  use child_process to run the command.)
* Update documentation.

Backport-PR-URL: #23630
PR-URL: #23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
rvagg pushed a commit that referenced this pull request Nov 28, 2018
Change common.ddCommand() to common.createZeroFilledFile().

Backport-PR-URL: #23630
PR-URL: #23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
MylesBorins pushed a commit that referenced this pull request Nov 29, 2018
* Remove different paths for Windows and POSIX.
* Remove fixtures file. Simply run the command immediately/directly.
* Since it is never called with more than one value for kilobytes,
  eliminate that argument.
* Update/simplify tests that use this function. (They no longer need to
  use child_process to run the command.)
* Update documentation.

Backport-PR-URL: #23630
PR-URL: #23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
MylesBorins pushed a commit that referenced this pull request Nov 29, 2018
Change common.ddCommand() to common.createZeroFilledFile().

Backport-PR-URL: #23630
PR-URL: #23411
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: George Adams <[email protected]>
@codebytere codebytere mentioned this pull request Nov 29, 2018
@Trott Trott deleted the dd 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
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.