2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-06-04 19:09:29 -04:00
|
|
|
|
2020-06-11 12:36:20 -04:00
|
|
|
import {
|
|
|
|
assert,
|
|
|
|
assertEquals,
|
2021-09-22 09:21:11 -04:00
|
|
|
assertRejects,
|
2020-06-24 18:57:08 -04:00
|
|
|
assertThrows,
|
2020-06-11 12:36:20 -04:00
|
|
|
pathToAbsoluteFileUrl,
|
|
|
|
} from "./test_util.ts";
|
2018-09-11 15:38:53 -04:00
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(
|
2021-09-22 19:50:50 -04:00
|
|
|
{ permissions: { read: true, write: true } },
|
2021-08-05 07:08:58 -04:00
|
|
|
function statSyncSuccess() {
|
2021-08-11 10:20:47 -04:00
|
|
|
const readmeInfo = Deno.statSync("README.md");
|
|
|
|
assert(readmeInfo.isFile);
|
|
|
|
assert(!readmeInfo.isSymlink);
|
2020-04-27 14:09:56 -04:00
|
|
|
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
const modulesInfo = Deno.statSync("tests/testdata/symlink_to_subdir");
|
2020-04-27 14:09:56 -04:00
|
|
|
assert(modulesInfo.isDirectory);
|
|
|
|
assert(!modulesInfo.isSymlink);
|
|
|
|
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
const testsInfo = Deno.statSync("tests");
|
2020-04-27 14:09:56 -04:00
|
|
|
assert(testsInfo.isDirectory);
|
|
|
|
assert(!testsInfo.isSymlink);
|
|
|
|
|
|
|
|
const tempFile = Deno.makeTempFileSync();
|
|
|
|
const tempInfo = Deno.statSync(tempFile);
|
2020-06-11 12:36:20 -04:00
|
|
|
let now = Date.now();
|
2020-04-27 14:09:56 -04:00
|
|
|
assert(tempInfo.atime !== null && now - tempInfo.atime.valueOf() < 1000);
|
|
|
|
assert(tempInfo.mtime !== null && now - tempInfo.mtime.valueOf() < 1000);
|
|
|
|
assert(
|
2020-07-14 15:24:17 -04:00
|
|
|
tempInfo.birthtime === null || now - tempInfo.birthtime.valueOf() < 1000,
|
2020-04-27 14:09:56 -04:00
|
|
|
);
|
2020-06-11 12:36:20 -04:00
|
|
|
|
2021-08-11 10:20:47 -04:00
|
|
|
const readmeInfoByUrl = Deno.statSync(pathToAbsoluteFileUrl("README.md"));
|
|
|
|
assert(readmeInfoByUrl.isFile);
|
|
|
|
assert(!readmeInfoByUrl.isSymlink);
|
2020-06-11 12:36:20 -04:00
|
|
|
|
|
|
|
const modulesInfoByUrl = Deno.statSync(
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
pathToAbsoluteFileUrl("tests/testdata/symlink_to_subdir"),
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
assert(modulesInfoByUrl.isDirectory);
|
|
|
|
assert(!modulesInfoByUrl.isSymlink);
|
|
|
|
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
const testsInfoByUrl = Deno.statSync(pathToAbsoluteFileUrl("tests"));
|
2020-06-11 12:36:20 -04:00
|
|
|
assert(testsInfoByUrl.isDirectory);
|
|
|
|
assert(!testsInfoByUrl.isSymlink);
|
|
|
|
|
|
|
|
const tempFileForUrl = Deno.makeTempFileSync();
|
|
|
|
const tempInfoByUrl = Deno.statSync(
|
|
|
|
new URL(
|
2020-07-14 15:24:17 -04:00
|
|
|
`file://${Deno.build.os === "windows" ? "/" : ""}${tempFileForUrl}`,
|
|
|
|
),
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
now = Date.now();
|
|
|
|
assert(
|
2020-07-14 15:24:17 -04:00
|
|
|
tempInfoByUrl.atime !== null &&
|
|
|
|
now - tempInfoByUrl.atime.valueOf() < 1000,
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
assert(
|
2020-07-14 15:24:17 -04:00
|
|
|
tempInfoByUrl.mtime !== null &&
|
|
|
|
now - tempInfoByUrl.mtime.valueOf() < 1000,
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
assert(
|
|
|
|
tempInfoByUrl.birthtime === null ||
|
2020-07-14 15:24:17 -04:00
|
|
|
now - tempInfoByUrl.birthtime.valueOf() < 1000,
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
Deno.removeSync(tempFile, { recursive: true });
|
|
|
|
Deno.removeSync(tempFileForUrl, { recursive: true });
|
2020-07-14 15:24:17 -04:00
|
|
|
},
|
2020-04-27 14:09:56 -04:00
|
|
|
);
|
2018-09-11 15:38:53 -04:00
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test({ permissions: { read: false } }, function statSyncPerm() {
|
2020-06-24 18:57:08 -04:00
|
|
|
assertThrows(() => {
|
2019-10-31 22:33:27 -04:00
|
|
|
Deno.statSync("README.md");
|
2020-06-24 18:57:08 -04:00
|
|
|
}, Deno.errors.PermissionDenied);
|
2019-02-08 15:59:38 -05:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test({ permissions: { read: true } }, function statSyncNotFound() {
|
2021-10-11 09:21:18 -04:00
|
|
|
assertThrows(
|
|
|
|
() => {
|
|
|
|
Deno.statSync("bad_file_name");
|
|
|
|
},
|
|
|
|
Deno.errors.NotFound,
|
|
|
|
`stat 'bad_file_name'`,
|
|
|
|
);
|
2018-09-11 15:38:53 -04:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test({ permissions: { read: true } }, function lstatSyncSuccess() {
|
2019-10-31 22:33:27 -04:00
|
|
|
const packageInfo = Deno.lstatSync("README.md");
|
2020-04-16 01:40:30 -04:00
|
|
|
assert(packageInfo.isFile);
|
|
|
|
assert(!packageInfo.isSymlink);
|
2018-09-11 15:38:53 -04:00
|
|
|
|
2020-06-11 12:36:20 -04:00
|
|
|
const packageInfoByUrl = Deno.lstatSync(pathToAbsoluteFileUrl("README.md"));
|
|
|
|
assert(packageInfoByUrl.isFile);
|
|
|
|
assert(!packageInfoByUrl.isSymlink);
|
|
|
|
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
const modulesInfo = Deno.lstatSync("tests/testdata/symlink_to_subdir");
|
2020-04-16 01:40:30 -04:00
|
|
|
assert(!modulesInfo.isDirectory);
|
|
|
|
assert(modulesInfo.isSymlink);
|
2018-09-11 15:38:53 -04:00
|
|
|
|
2020-06-11 12:36:20 -04:00
|
|
|
const modulesInfoByUrl = Deno.lstatSync(
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
pathToAbsoluteFileUrl("tests/testdata/symlink_to_subdir"),
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
assert(!modulesInfoByUrl.isDirectory);
|
|
|
|
assert(modulesInfoByUrl.isSymlink);
|
|
|
|
|
2023-07-01 20:00:14 -04:00
|
|
|
const coreInfo = Deno.lstatSync("cli");
|
2020-04-16 01:40:30 -04:00
|
|
|
assert(coreInfo.isDirectory);
|
|
|
|
assert(!coreInfo.isSymlink);
|
2020-06-11 12:36:20 -04:00
|
|
|
|
2023-07-01 20:00:14 -04:00
|
|
|
const coreInfoByUrl = Deno.lstatSync(pathToAbsoluteFileUrl("cli"));
|
2020-06-11 12:36:20 -04:00
|
|
|
assert(coreInfoByUrl.isDirectory);
|
|
|
|
assert(!coreInfoByUrl.isSymlink);
|
2018-09-11 15:38:53 -04:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test({ permissions: { read: false } }, function lstatSyncPerm() {
|
2020-06-24 18:57:08 -04:00
|
|
|
assertThrows(() => {
|
2022-09-19 10:32:21 -04:00
|
|
|
Deno.lstatSync("assets/hello.txt");
|
2020-06-24 18:57:08 -04:00
|
|
|
}, Deno.errors.PermissionDenied);
|
2019-02-08 15:59:38 -05:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test({ permissions: { read: true } }, function lstatSyncNotFound() {
|
2021-10-11 09:21:18 -04:00
|
|
|
assertThrows(
|
|
|
|
() => {
|
|
|
|
Deno.lstatSync("bad_file_name");
|
|
|
|
},
|
|
|
|
Deno.errors.NotFound,
|
|
|
|
`stat 'bad_file_name'`,
|
|
|
|
);
|
2018-09-11 15:38:53 -04:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(
|
2021-09-22 19:50:50 -04:00
|
|
|
{ permissions: { read: true, write: true } },
|
2021-08-05 07:08:58 -04:00
|
|
|
async function statSuccess() {
|
2021-08-11 10:20:47 -04:00
|
|
|
const readmeInfo = await Deno.stat("README.md");
|
|
|
|
assert(readmeInfo.isFile);
|
|
|
|
assert(!readmeInfo.isSymlink);
|
2020-04-27 14:09:56 -04:00
|
|
|
|
2021-08-11 10:20:47 -04:00
|
|
|
const readmeInfoByUrl = await Deno.stat(
|
2020-07-14 15:24:17 -04:00
|
|
|
pathToAbsoluteFileUrl("README.md"),
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
2021-08-11 10:20:47 -04:00
|
|
|
assert(readmeInfoByUrl.isFile);
|
|
|
|
assert(!readmeInfoByUrl.isSymlink);
|
2020-06-11 12:36:20 -04:00
|
|
|
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
const modulesInfo = await Deno.stat("tests/testdata/symlink_to_subdir");
|
2020-04-27 14:09:56 -04:00
|
|
|
assert(modulesInfo.isDirectory);
|
|
|
|
assert(!modulesInfo.isSymlink);
|
|
|
|
|
2020-06-11 12:36:20 -04:00
|
|
|
const modulesInfoByUrl = await Deno.stat(
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
pathToAbsoluteFileUrl("tests/testdata/symlink_to_subdir"),
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
assert(modulesInfoByUrl.isDirectory);
|
|
|
|
assert(!modulesInfoByUrl.isSymlink);
|
|
|
|
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
const testsInfo = await Deno.stat("tests");
|
2020-04-27 14:09:56 -04:00
|
|
|
assert(testsInfo.isDirectory);
|
|
|
|
assert(!testsInfo.isSymlink);
|
|
|
|
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
const testsInfoByUrl = await Deno.stat(pathToAbsoluteFileUrl("tests"));
|
2020-06-11 12:36:20 -04:00
|
|
|
assert(testsInfoByUrl.isDirectory);
|
|
|
|
assert(!testsInfoByUrl.isSymlink);
|
|
|
|
|
2020-04-27 14:09:56 -04:00
|
|
|
const tempFile = await Deno.makeTempFile();
|
|
|
|
const tempInfo = await Deno.stat(tempFile);
|
2020-06-11 12:36:20 -04:00
|
|
|
let now = Date.now();
|
2020-04-27 14:09:56 -04:00
|
|
|
assert(tempInfo.atime !== null && now - tempInfo.atime.valueOf() < 1000);
|
|
|
|
assert(tempInfo.mtime !== null && now - tempInfo.mtime.valueOf() < 1000);
|
|
|
|
|
|
|
|
assert(
|
2020-07-14 15:24:17 -04:00
|
|
|
tempInfo.birthtime === null || now - tempInfo.birthtime.valueOf() < 1000,
|
2020-04-27 14:09:56 -04:00
|
|
|
);
|
2020-06-11 12:36:20 -04:00
|
|
|
|
|
|
|
const tempFileForUrl = await Deno.makeTempFile();
|
|
|
|
const tempInfoByUrl = await Deno.stat(
|
|
|
|
new URL(
|
2020-07-14 15:24:17 -04:00
|
|
|
`file://${Deno.build.os === "windows" ? "/" : ""}${tempFileForUrl}`,
|
|
|
|
),
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
now = Date.now();
|
|
|
|
assert(
|
2020-07-14 15:24:17 -04:00
|
|
|
tempInfoByUrl.atime !== null &&
|
|
|
|
now - tempInfoByUrl.atime.valueOf() < 1000,
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
assert(
|
2020-07-14 15:24:17 -04:00
|
|
|
tempInfoByUrl.mtime !== null &&
|
|
|
|
now - tempInfoByUrl.mtime.valueOf() < 1000,
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
assert(
|
|
|
|
tempInfoByUrl.birthtime === null ||
|
2020-07-14 15:24:17 -04:00
|
|
|
now - tempInfoByUrl.birthtime.valueOf() < 1000,
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
Deno.removeSync(tempFile, { recursive: true });
|
|
|
|
Deno.removeSync(tempFileForUrl, { recursive: true });
|
2020-07-14 15:24:17 -04:00
|
|
|
},
|
2020-04-27 14:09:56 -04:00
|
|
|
);
|
2018-09-11 15:38:53 -04:00
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test({ permissions: { read: false } }, async function statPerm() {
|
2021-09-22 09:21:11 -04:00
|
|
|
await assertRejects(async () => {
|
2019-10-31 22:33:27 -04:00
|
|
|
await Deno.stat("README.md");
|
2020-06-24 18:57:08 -04:00
|
|
|
}, Deno.errors.PermissionDenied);
|
2019-02-08 15:59:38 -05:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test({ permissions: { read: true } }, async function statNotFound() {
|
2021-09-22 09:21:11 -04:00
|
|
|
await assertRejects(
|
2021-08-05 07:08:58 -04:00
|
|
|
async () => {
|
2021-10-11 09:21:18 -04:00
|
|
|
await Deno.stat("bad_file_name");
|
2020-07-14 15:24:17 -04:00
|
|
|
},
|
2021-10-11 09:21:18 -04:00
|
|
|
Deno.errors.NotFound,
|
|
|
|
`stat 'bad_file_name'`,
|
2020-06-24 18:57:08 -04:00
|
|
|
);
|
2018-09-11 15:38:53 -04:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test({ permissions: { read: true } }, async function lstatSuccess() {
|
2021-08-11 10:20:47 -04:00
|
|
|
const readmeInfo = await Deno.lstat("README.md");
|
|
|
|
assert(readmeInfo.isFile);
|
|
|
|
assert(!readmeInfo.isSymlink);
|
2018-09-11 15:38:53 -04:00
|
|
|
|
2021-08-11 10:20:47 -04:00
|
|
|
const readmeInfoByUrl = await Deno.lstat(pathToAbsoluteFileUrl("README.md"));
|
|
|
|
assert(readmeInfoByUrl.isFile);
|
|
|
|
assert(!readmeInfoByUrl.isSymlink);
|
2020-06-11 12:36:20 -04:00
|
|
|
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
const modulesInfo = await Deno.lstat("tests/testdata/symlink_to_subdir");
|
2020-04-16 01:40:30 -04:00
|
|
|
assert(!modulesInfo.isDirectory);
|
|
|
|
assert(modulesInfo.isSymlink);
|
2018-09-11 15:38:53 -04:00
|
|
|
|
2020-06-11 12:36:20 -04:00
|
|
|
const modulesInfoByUrl = await Deno.lstat(
|
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.
2024-02-10 15:22:13 -05:00
|
|
|
pathToAbsoluteFileUrl("tests/testdata/symlink_to_subdir"),
|
2020-06-11 12:36:20 -04:00
|
|
|
);
|
|
|
|
assert(!modulesInfoByUrl.isDirectory);
|
|
|
|
assert(modulesInfoByUrl.isSymlink);
|
|
|
|
|
2023-07-01 20:00:14 -04:00
|
|
|
const coreInfo = await Deno.lstat("cli");
|
2020-04-16 01:40:30 -04:00
|
|
|
assert(coreInfo.isDirectory);
|
|
|
|
assert(!coreInfo.isSymlink);
|
2020-06-11 12:36:20 -04:00
|
|
|
|
2023-07-01 20:00:14 -04:00
|
|
|
const coreInfoByUrl = await Deno.lstat(pathToAbsoluteFileUrl("cli"));
|
2020-06-11 12:36:20 -04:00
|
|
|
assert(coreInfoByUrl.isDirectory);
|
|
|
|
assert(!coreInfoByUrl.isSymlink);
|
2018-09-11 15:38:53 -04:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test({ permissions: { read: false } }, async function lstatPerm() {
|
2021-09-22 09:21:11 -04:00
|
|
|
await assertRejects(async () => {
|
2019-10-31 22:33:27 -04:00
|
|
|
await Deno.lstat("README.md");
|
2020-06-24 18:57:08 -04:00
|
|
|
}, Deno.errors.PermissionDenied);
|
2019-02-08 15:59:38 -05:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test({ permissions: { read: true } }, async function lstatNotFound() {
|
2021-10-11 09:21:18 -04:00
|
|
|
await assertRejects(
|
|
|
|
async () => {
|
|
|
|
await Deno.lstat("bad_file_name");
|
|
|
|
},
|
|
|
|
Deno.errors.NotFound,
|
|
|
|
`stat 'bad_file_name'`,
|
|
|
|
);
|
2018-09-11 15:38:53 -04:00
|
|
|
});
|
2020-01-16 09:46:32 -05:00
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(
|
2021-09-22 19:50:50 -04:00
|
|
|
{
|
|
|
|
ignore: Deno.build.os !== "windows",
|
|
|
|
permissions: { read: true, write: true },
|
|
|
|
},
|
2023-03-16 19:14:56 -04:00
|
|
|
function statNoUnixFields() {
|
2020-03-04 11:31:14 -05:00
|
|
|
const enc = new TextEncoder();
|
|
|
|
const data = enc.encode("Hello");
|
|
|
|
const tempDir = Deno.makeTempDirSync();
|
|
|
|
const filename = tempDir + "/test.txt";
|
2020-03-07 22:29:12 -05:00
|
|
|
Deno.writeFileSync(filename, data, { mode: 0o666 });
|
2020-03-04 11:31:14 -05:00
|
|
|
const s = Deno.statSync(filename);
|
2023-03-15 21:35:13 -04:00
|
|
|
assert(s.dev !== 0);
|
2023-03-16 19:14:56 -04:00
|
|
|
assert(s.ino === null);
|
|
|
|
assert(s.mode === null);
|
|
|
|
assert(s.nlink === null);
|
|
|
|
assert(s.uid === null);
|
|
|
|
assert(s.gid === null);
|
|
|
|
assert(s.rdev === null);
|
|
|
|
assert(s.blksize === null);
|
|
|
|
assert(s.blocks === null);
|
2023-05-24 15:18:13 -04:00
|
|
|
assert(s.isBlockDevice === null);
|
|
|
|
assert(s.isCharDevice === null);
|
|
|
|
assert(s.isFifo === null);
|
|
|
|
assert(s.isSocket === null);
|
2020-07-14 15:24:17 -04:00
|
|
|
},
|
2020-03-04 11:31:14 -05:00
|
|
|
);
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(
|
2021-09-22 19:50:50 -04:00
|
|
|
{
|
|
|
|
ignore: Deno.build.os === "windows",
|
|
|
|
permissions: { read: true, write: true },
|
|
|
|
},
|
2021-08-05 07:08:58 -04:00
|
|
|
function statUnixFields() {
|
2020-03-04 11:31:14 -05:00
|
|
|
const enc = new TextEncoder();
|
|
|
|
const data = enc.encode("Hello");
|
|
|
|
const tempDir = Deno.makeTempDirSync();
|
|
|
|
const filename = tempDir + "/test.txt";
|
|
|
|
const filename2 = tempDir + "/test2.txt";
|
2020-03-07 22:29:12 -05:00
|
|
|
Deno.writeFileSync(filename, data, { mode: 0o666 });
|
2020-03-04 11:31:14 -05:00
|
|
|
// Create a link
|
|
|
|
Deno.linkSync(filename, filename2);
|
|
|
|
const s = Deno.statSync(filename);
|
|
|
|
assert(s.dev !== null);
|
|
|
|
assert(s.ino !== null);
|
|
|
|
assertEquals(s.mode! & 0o666, 0o666);
|
|
|
|
assertEquals(s.nlink, 2);
|
|
|
|
assert(s.uid !== null);
|
|
|
|
assert(s.gid !== null);
|
|
|
|
assert(s.rdev !== null);
|
|
|
|
assert(s.blksize !== null);
|
|
|
|
assert(s.blocks !== null);
|
2023-05-24 15:18:13 -04:00
|
|
|
assert(!s.isBlockDevice);
|
|
|
|
assert(!s.isCharDevice);
|
|
|
|
assert(!s.isFifo);
|
|
|
|
assert(!s.isSocket);
|
2020-07-14 15:24:17 -04:00
|
|
|
},
|
2020-03-04 11:31:14 -05:00
|
|
|
);
|