node/test/parallel/test-require-long-path.js
Rafał Pocztarski 19e06d71cf test: skip long path tests on non-Windows
If not running on Windows it skips the long path tests in:

* test-fs-long-path.js
* test-require-long-path.js

Fixes: https://github.com/nodejs/node/issues/2255
PR-URL: https://github.com/nodejs/node/pull/4116
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
2015-12-07 12:10:24 +01:00

29 lines
742 B
JavaScript

'use strict';
const common = require('../common');
const fs = require('fs');
const path = require('path');
if (!common.isWindows) {
console.log('1..0 # Skipped: this test is Windows-specific.');
return;
}
// make a path that is more than 260 chars long.
const dirNameLen = Math.max(260 - common.tmpDir.length, 1);
const dirName = path.join(common.tmpDir, 'x'.repeat(dirNameLen));
const fullDirPath = path.resolve(dirName);
const indexFile = path.join(fullDirPath, 'index.js');
const otherFile = path.join(fullDirPath, 'other.js');
common.refreshTmpDir();
fs.mkdirSync(fullDirPath);
fs.writeFileSync(indexFile, 'require("./other");');
fs.writeFileSync(otherFile, '');
require(indexFile);
require(otherFile);
common.refreshTmpDir();