diff options
author | Matt Mastracci <matthew@mastracci.com> | 2024-02-10 13:22:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-10 20:22:13 +0000 |
commit | f5e46c9bf2f50d66a953fa133161fc829cecff06 (patch) | |
tree | 8faf2f5831c1c7b11d842cd9908d141082c869a5 /cli/tests/node_compat/test/parallel/test-url-fileurltopath.js | |
parent | d2477f780630a812bfd65e3987b70c0d309385bb (diff) |
chore: move cli/tests/ -> tests/ (#22369)
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.
Diffstat (limited to 'cli/tests/node_compat/test/parallel/test-url-fileurltopath.js')
-rw-r--r-- | cli/tests/node_compat/test/parallel/test-url-fileurltopath.js | 161 |
1 files changed, 0 insertions, 161 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-url-fileurltopath.js b/cli/tests/node_compat/test/parallel/test-url-fileurltopath.js deleted file mode 100644 index 72ba73166..000000000 --- a/cli/tests/node_compat/test/parallel/test-url-fileurltopath.js +++ /dev/null @@ -1,161 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 18.12.1 -// This file is automatically generated by `tools/node_compat/setup.ts`. Do not modify this file manually. - -'use strict'; -const { isWindows } = require('../common'); -const assert = require('assert'); -const url = require('url'); - -function testInvalidArgs(...args) { - for (const arg of args) { - assert.throws(() => url.fileURLToPath(arg), { - code: 'ERR_INVALID_ARG_TYPE' - }); - } -} - -// Input must be string or URL -testInvalidArgs(null, undefined, 1, {}, true); - -// Input must be a file URL -assert.throws(() => url.fileURLToPath('https://a/b/c'), { - code: 'ERR_INVALID_URL_SCHEME' -}); - -{ - const withHost = new URL('file://host/a'); - - if (isWindows) { - assert.strictEqual(url.fileURLToPath(withHost), '\\\\host\\a'); - } else { - assert.throws(() => url.fileURLToPath(withHost), { - code: 'ERR_INVALID_FILE_URL_HOST' - }); - } -} - -{ - if (isWindows) { - assert.throws(() => url.fileURLToPath('file:///C:/a%2F/'), { - code: 'ERR_INVALID_FILE_URL_PATH' - }); - assert.throws(() => url.fileURLToPath('file:///C:/a%5C/'), { - code: 'ERR_INVALID_FILE_URL_PATH' - }); - assert.throws(() => url.fileURLToPath('file:///?:/'), { - code: 'ERR_INVALID_FILE_URL_PATH' - }); - } else { - assert.throws(() => url.fileURLToPath('file:///a%2F/'), { - code: 'ERR_INVALID_FILE_URL_PATH' - }); - } -} - -{ - let testCases; - if (isWindows) { - testCases = [ - // Lowercase ascii alpha - { path: 'C:\\foo', fileURL: 'file:///C:/foo' }, - // Uppercase ascii alpha - { path: 'C:\\FOO', fileURL: 'file:///C:/FOO' }, - // dir - { path: 'C:\\dir\\foo', fileURL: 'file:///C:/dir/foo' }, - // trailing separator - { path: 'C:\\dir\\', fileURL: 'file:///C:/dir/' }, - // dot - { path: 'C:\\foo.mjs', fileURL: 'file:///C:/foo.mjs' }, - // space - { path: 'C:\\foo bar', fileURL: 'file:///C:/foo%20bar' }, - // question mark - { path: 'C:\\foo?bar', fileURL: 'file:///C:/foo%3Fbar' }, - // number sign - { path: 'C:\\foo#bar', fileURL: 'file:///C:/foo%23bar' }, - // ampersand - { path: 'C:\\foo&bar', fileURL: 'file:///C:/foo&bar' }, - // equals - { path: 'C:\\foo=bar', fileURL: 'file:///C:/foo=bar' }, - // colon - { path: 'C:\\foo:bar', fileURL: 'file:///C:/foo:bar' }, - // semicolon - { path: 'C:\\foo;bar', fileURL: 'file:///C:/foo;bar' }, - // percent - { path: 'C:\\foo%bar', fileURL: 'file:///C:/foo%25bar' }, - // backslash - { path: 'C:\\foo\\bar', fileURL: 'file:///C:/foo/bar' }, - // backspace - { path: 'C:\\foo\bbar', fileURL: 'file:///C:/foo%08bar' }, - // tab - { path: 'C:\\foo\tbar', fileURL: 'file:///C:/foo%09bar' }, - // newline - { path: 'C:\\foo\nbar', fileURL: 'file:///C:/foo%0Abar' }, - // carriage return - { path: 'C:\\foo\rbar', fileURL: 'file:///C:/foo%0Dbar' }, - // latin1 - { path: 'C:\\fóóbàr', fileURL: 'file:///C:/f%C3%B3%C3%B3b%C3%A0r' }, - // Euro sign (BMP code point) - { path: 'C:\\€', fileURL: 'file:///C:/%E2%82%AC' }, - // Rocket emoji (non-BMP code point) - { path: 'C:\\🚀', fileURL: 'file:///C:/%F0%9F%9A%80' }, - // UNC path (see https://docs.microsoft.com/en-us/archive/blogs/ie/file-uris-in-windows) - { path: '\\\\nas\\My Docs\\File.doc', fileURL: 'file://nas/My%20Docs/File.doc' }, - ]; - } else { - testCases = [ - // Lowercase ascii alpha - { path: '/foo', fileURL: 'file:///foo' }, - // Uppercase ascii alpha - { path: '/FOO', fileURL: 'file:///FOO' }, - // dir - { path: '/dir/foo', fileURL: 'file:///dir/foo' }, - // trailing separator - { path: '/dir/', fileURL: 'file:///dir/' }, - // dot - { path: '/foo.mjs', fileURL: 'file:///foo.mjs' }, - // space - { path: '/foo bar', fileURL: 'file:///foo%20bar' }, - // question mark - { path: '/foo?bar', fileURL: 'file:///foo%3Fbar' }, - // number sign - { path: '/foo#bar', fileURL: 'file:///foo%23bar' }, - // ampersand - { path: '/foo&bar', fileURL: 'file:///foo&bar' }, - // equals - { path: '/foo=bar', fileURL: 'file:///foo=bar' }, - // colon - { path: '/foo:bar', fileURL: 'file:///foo:bar' }, - // semicolon - { path: '/foo;bar', fileURL: 'file:///foo;bar' }, - // percent - { path: '/foo%bar', fileURL: 'file:///foo%25bar' }, - // backslash - { path: '/foo\\bar', fileURL: 'file:///foo%5Cbar' }, - // backspace - { path: '/foo\bbar', fileURL: 'file:///foo%08bar' }, - // tab - { path: '/foo\tbar', fileURL: 'file:///foo%09bar' }, - // newline - { path: '/foo\nbar', fileURL: 'file:///foo%0Abar' }, - // carriage return - { path: '/foo\rbar', fileURL: 'file:///foo%0Dbar' }, - // latin1 - { path: '/fóóbàr', fileURL: 'file:///f%C3%B3%C3%B3b%C3%A0r' }, - // Euro sign (BMP code point) - { path: '/€', fileURL: 'file:///%E2%82%AC' }, - // Rocket emoji (non-BMP code point) - { path: '/🚀', fileURL: 'file:///%F0%9F%9A%80' }, - ]; - } - - for (const { path, fileURL } of testCases) { - const fromString = url.fileURLToPath(fileURL); - assert.strictEqual(fromString, path); - const fromURL = url.fileURLToPath(new URL(fileURL)); - assert.strictEqual(fromURL, path); - } -} |