diff options
author | James M Snell <jasnell@gmail.com> | 2017-07-17 15:33:46 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-08-07 18:00:57 -0700 |
commit | 7535a94c8a54bb6346c8e60dbae1c32d6f508212 (patch) | |
tree | e455c85470c3256bb064516a8fa8e2c4c059532b /test/parallel/test-require-symlink.js | |
parent | 7192e913f703c96eddff697c4ba0daef87930776 (diff) | |
download | android-node-v8-7535a94c8a54bb6346c8e60dbae1c32d6f508212.tar.gz android-node-v8-7535a94c8a54bb6346c8e60dbae1c32d6f508212.tar.bz2 android-node-v8-7535a94c8a54bb6346c8e60dbae1c32d6f508212.zip |
test: begin normalizing fixtures use
Adds a new `../common/fixtures' module to begin normalizing
`test/fixtures` use. Our test code is a bit inconsistent with
regards to use of the fixtures directory. Some code uses
`path.join()`, some code uses string concats, some other
code uses template strings, etc. In mnay cases, significant
duplication of code is seen when accessing fixture files, etc.
This updates many (but by no means all) of the tests in the
test suite to use the new consistent API. There are still
many more to update, which would make an excelent Code-n-Learn
exercise.
PR-URL: https://github.com/nodejs/node/pull/14332
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Diffstat (limited to 'test/parallel/test-require-symlink.js')
-rw-r--r-- | test/parallel/test-require-symlink.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/test/parallel/test-require-symlink.js b/test/parallel/test-require-symlink.js index 222494aaf1..8f15845947 100644 --- a/test/parallel/test-require-symlink.js +++ b/test/parallel/test-require-symlink.js @@ -6,19 +6,22 @@ const path = require('path'); const fs = require('fs'); const { exec, spawn } = require('child_process'); const util = require('util'); +const fixtures = require('../common/fixtures'); common.refreshTmpDir(); -const linkTarget = path.join(common.fixturesDir, - '/module-require-symlink/node_modules/dep2/'); +const linkTarget = fixtures.path('module-require-symlink', + 'node_modules', + 'dep2'); -const linkDir = path.join( - common.fixturesDir, - '/module-require-symlink/node_modules/dep1/node_modules/dep2' -); +const linkDir = fixtures.path('module-require-symlink', + 'node_modules', + 'dep1', + 'node_modules', + 'dep2'); -const linkScriptTarget = path.join(common.fixturesDir, - '/module-require-symlink/symlinked.js'); +const linkScriptTarget = fixtures.path('module-require-symlink', + 'symlinked.js'); const linkScript = path.join(common.tmpDir, 'module-require-symlink.js'); @@ -44,8 +47,7 @@ function test() { fs.symlinkSync(linkScriptTarget, linkScript); // load symlinked-module - const fooModule = - require(path.join(common.fixturesDir, '/module-require-symlink/foo.js')); + const fooModule = require(fixtures.path('/module-require-symlink/foo.js')); assert.strictEqual(fooModule.dep1.bar.version, 'CORRECT_VERSION'); assert.strictEqual(fooModule.dep2.bar.version, 'CORRECT_VERSION'); |