mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
f5e46c9bf2
This looks like a massive PR, but it's only a move from cli/tests -> tests, and updates of relative paths for files. This is the first step towards aggregate all of the integration test files under tests/, which will lead to a set of integration tests that can run without the CLI binary being built. While we could leave these tests under `cli`, it would require us to keep a more complex directory structure for the various test runners. In addition, we have a lot of complexity to ignore various test files in the `cli` project itself (cargo publish exclusion rules, autotests = false, etc). And finally, the `tests/` folder will eventually house the `test_ffi`, `test_napi` and other testing code, reducing the size of the root repo directory. For easier review, the extremely large and noisy "move" is in the first commit (with no changes -- just a move), while the remainder of the changes to actual files is in the second commit.
96 lines
3.5 KiB
JavaScript
96 lines
3.5 KiB
JavaScript
// deno-fmt-ignore-file
|
|
// deno-lint-ignore-file
|
|
|
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
|
// Taken from Node 16.13.0
|
|
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
|
|
|
'use strict';
|
|
const common = require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
const assert = require('assert');
|
|
const child = require('child_process');
|
|
const path = require('path');
|
|
|
|
const failures = [];
|
|
const slashRE = /\//g;
|
|
const backslashRE = /\\/g;
|
|
|
|
const posixyCwd = common.isWindows ?
|
|
(() => {
|
|
const _ = process.cwd()
|
|
.replaceAll(path.sep, path.posix.sep);
|
|
return _.slice(_.indexOf(path.posix.sep));
|
|
})() :
|
|
process.cwd();
|
|
|
|
const resolveTests = [
|
|
[ path.win32.resolve,
|
|
// Arguments result
|
|
[[['c:/blah\\blah', 'd:/games', 'c:../a'], 'c:\\blah\\a'],
|
|
[['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'], 'd:\\e.exe'],
|
|
[['c:/ignore', 'c:/some/file'], 'c:\\some\\file'],
|
|
[['d:/ignore', 'd:some/dir//'], 'd:\\ignore\\some\\dir'],
|
|
[['.'], process.cwd()],
|
|
[['//server/share', '..', 'relative\\'], '\\\\server\\share\\relative'],
|
|
[['c:/', '//'], 'c:\\'],
|
|
[['c:/', '//dir'], 'c:\\dir'],
|
|
[['c:/', '//server/share'], '\\\\server\\share\\'],
|
|
[['c:/', '//server//share'], '\\\\server\\share\\'],
|
|
[['c:/', '///some//dir'], 'c:\\some\\dir'],
|
|
[['C:\\foo\\tmp.3\\', '..\\tmp.3\\cycles\\root.js'],
|
|
'C:\\foo\\tmp.3\\cycles\\root.js'],
|
|
],
|
|
],
|
|
[ path.posix.resolve,
|
|
// Arguments result
|
|
[[['/var/lib', '../', 'file/'], '/var/file'],
|
|
[['/var/lib', '/../', 'file/'], '/file'],
|
|
// TODO(wafuwafu13): Enable this
|
|
// [['a/b/c/', '../../..'], posixyCwd],
|
|
// [['.'], posixyCwd],
|
|
[['/some/dir', '.', '/absolute/'], '/absolute'],
|
|
[['/foo/tmp.3/', '../tmp.3/cycles/root.js'], '/foo/tmp.3/cycles/root.js'],
|
|
],
|
|
],
|
|
];
|
|
resolveTests.forEach(([resolve, tests]) => {
|
|
tests.forEach(([test, expected]) => {
|
|
const actual = resolve.apply(null, test);
|
|
let actualAlt;
|
|
const os = resolve === path.win32.resolve ? 'win32' : 'posix';
|
|
if (resolve === path.win32.resolve && !common.isWindows)
|
|
actualAlt = actual.replace(backslashRE, '/');
|
|
else if (resolve !== path.win32.resolve && common.isWindows)
|
|
actualAlt = actual.replace(slashRE, '\\');
|
|
|
|
const message =
|
|
`path.${os}.resolve(${test.map(JSON.stringify).join(',')})\n expect=${
|
|
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
|
|
if (actual !== expected && actualAlt !== expected)
|
|
failures.push(message);
|
|
});
|
|
});
|
|
assert.strictEqual(failures.length, 0, failures.join('\n'));
|
|
|
|
if (common.isWindows) {
|
|
// Test resolving the current Windows drive letter from a spawned process.
|
|
// See https://github.com/nodejs/node/issues/7215
|
|
const currentDriveLetter = path.parse(process.cwd()).root.substring(0, 2);
|
|
const resolveFixture = fixtures.path('path-resolve.js');
|
|
// TODO(wafuwafu13): Enable this
|
|
// const spawnResult = child.spawnSync(
|
|
// process.argv[0], [resolveFixture, currentDriveLetter]);
|
|
// const resolvedPath = spawnResult.stdout.toString().trim();
|
|
// assert.strictEqual(resolvedPath.toLowerCase(), process.cwd().toLowerCase());
|
|
}
|
|
|
|
if (!common.isWindows) {
|
|
// Test handling relative paths to be safe when process.cwd() fails.
|
|
process.cwd = () => '';
|
|
assert.strictEqual(process.cwd(), '');
|
|
const resolved = path.resolve();
|
|
const expected = '.';
|
|
// TODO(wafuwafu13): Enable this
|
|
// assert.strictEqual(resolved, expected);
|
|
}
|