зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 58e0c5dca806 (bug 1705484
) for failures on test_ioutils_copy_move.html. CLOSED TREE
This commit is contained in:
Родитель
c13165d08c
Коммит
24bec48837
|
@ -9,10 +9,13 @@
|
|||
importScripts("chrome://mochikit/content/tests/SimpleTest/WorkerSimpleTest.js");
|
||||
importScripts("resource://gre/modules/ObjectUtils.jsm");
|
||||
|
||||
// TODO: Remove this import for OS.File. It is currently being used as a
|
||||
// stop gap for missing IOUtils functionality.
|
||||
importScripts("resource://gre/modules/osfile.jsm");
|
||||
importScripts("file_ioutils_test_fixtures.js");
|
||||
|
||||
self.onmessage = async function(msg) {
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpDir = OS.Constants.Path.tmpDir;
|
||||
|
||||
// IOUtils functionality is the same when called from the main thread, or a
|
||||
// web worker. These tests are a modified subset of the main thread tests, and
|
||||
|
@ -32,7 +35,7 @@ self.onmessage = async function(msg) {
|
|||
|
||||
async function test_full_read_and_write() {
|
||||
// Write a file.
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_numbers.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_numbers.tmp");
|
||||
const bytes = Uint8Array.of(...new Array(50).keys());
|
||||
const bytesWritten = await IOUtils.write(tmpFileName, bytes);
|
||||
is(bytesWritten, 50, "IOUtils::write can write entire byte array to file");
|
||||
|
@ -57,8 +60,8 @@ self.onmessage = async function(msg) {
|
|||
}
|
||||
|
||||
async function test_move_file() {
|
||||
const src = PathUtils.join(tmpDir, "test_move_file_src.tmp");
|
||||
const dest = PathUtils.join(tmpDir, "test_move_file_dest.tmp");
|
||||
const src = OS.Path.join(tmpDir, "test_move_file_src.tmp");
|
||||
const dest = OS.Path.join(tmpDir, "test_move_file_dest.tmp");
|
||||
const bytes = Uint8Array.of(...new Array(50).keys());
|
||||
await IOUtils.write(src, bytes);
|
||||
|
||||
|
@ -72,8 +75,8 @@ self.onmessage = async function(msg) {
|
|||
}
|
||||
|
||||
async function test_copy_file() {
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_orig.tmp");
|
||||
const destFileName = PathUtils.join(tmpDir, "test_ioutils_copy.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_orig.tmp");
|
||||
const destFileName = OS.Path.join(tmpDir, "test_ioutils_copy.tmp");
|
||||
await createFile(tmpFileName, "original");
|
||||
|
||||
await IOUtils.copy(tmpFileName, destFileName);
|
||||
|
@ -87,12 +90,10 @@ self.onmessage = async function(msg) {
|
|||
}
|
||||
|
||||
async function test_make_directory() {
|
||||
const dir = PathUtils.join(tmpDir, "test_make_dir.tmp.d");
|
||||
const dir = OS.Path.join(tmpDir, "test_make_dir.tmp.d");
|
||||
await IOUtils.makeDirectory(dir);
|
||||
const stat = await IOUtils.stat(dir);
|
||||
is(
|
||||
stat.type,
|
||||
"directory",
|
||||
ok(
|
||||
OS.File.stat(dir).isDir,
|
||||
"IOUtils::makeDirectory can make a new directory from a worker"
|
||||
);
|
||||
|
||||
|
|
|
@ -15,9 +15,15 @@
|
|||
const { Assert } = ChromeUtils.import("resource://testing-common/Assert.jsm");
|
||||
const { ObjectUtils } = ChromeUtils.import("resource://gre/modules/ObjectUtils.jsm");
|
||||
|
||||
// TODO: Remove this import for OS.File. It is currently being used as a
|
||||
// stop gap for missing IOUtils functionality.
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
|
||||
|
||||
const tmpDir = OS.Constants.Path.tmpDir;
|
||||
|
||||
add_task(async function test_move_relative_path() {
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_move_relative_path.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_move_relative_path.tmp");
|
||||
const dest = "relative_to_cwd.tmp";
|
||||
await createFile(tmpFileName, "source");
|
||||
|
||||
|
@ -37,9 +43,8 @@
|
|||
|
||||
add_task(async function test_move_rename() {
|
||||
// Set up.
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_move_src.tmp");
|
||||
const destFileName = PathUtils.join(tmpDir, "test_ioutils_move_dest.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_move_src.tmp");
|
||||
const destFileName = OS.Path.join(tmpDir, "test_ioutils_move_dest.tmp");
|
||||
await createFile(tmpFileName, "dest");
|
||||
// Test.
|
||||
info("Test move to new file in same directory");
|
||||
|
@ -82,10 +87,9 @@
|
|||
add_task(async function test_move_to_dir() {
|
||||
// Set up.
|
||||
info("Test move and rename to non-existing directory");
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_move_to_dir.tmp");
|
||||
const destDir = PathUtils.join(tmpDir, "test_move_to_dir.tmp.d");
|
||||
const dest = PathUtils.join(destDir, "dest.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_move_to_dir.tmp");
|
||||
const destDir = OS.Path.join(tmpDir, "test_move_to_dir.tmp.d");
|
||||
const dest = OS.Path.join(destDir, "dest.tmp");
|
||||
await createFile(tmpFileName);
|
||||
// Test.
|
||||
ok(!await IOUtils.exists(destDir), "Expected path not to exist");
|
||||
|
@ -115,7 +119,7 @@
|
|||
ok(await dirExists(destDir), `Expected ${destDir} to be a directory`);
|
||||
ok(
|
||||
!await fileExists(tmpFileName)
|
||||
&& await fileExists(PathUtils.join(destDir, PathUtils.filename(tmpFileName))),
|
||||
&& await fileExists(OS.Path.join(destDir, OS.Path.basename(tmpFileName))),
|
||||
"IOUtils::move can move a file into an existing dir"
|
||||
);
|
||||
|
||||
|
@ -126,9 +130,8 @@
|
|||
add_task(async function test_move_dir() {
|
||||
// Set up.
|
||||
info("Test rename an empty directory");
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const srcDir = PathUtils.join(tmpDir, "test_move_dir.tmp.d");
|
||||
const destDir = PathUtils.join(tmpDir, "test_move_dir_dest.tmp.d");
|
||||
const srcDir = OS.Path.join(tmpDir, "test_move_dir.tmp.d");
|
||||
const destDir = OS.Path.join(tmpDir, "test_move_dir_dest.tmp.d");
|
||||
await createDir(srcDir);
|
||||
// Test.
|
||||
await IOUtils.move(srcDir, destDir);
|
||||
|
@ -140,14 +143,14 @@
|
|||
// Set up.
|
||||
info("Test move directory and its content into another directory");
|
||||
await createDir(srcDir);
|
||||
await createFile(PathUtils.join(srcDir, "file.tmp"), "foo");
|
||||
await createFile(OS.Path.join(srcDir, "file.tmp"), "foo");
|
||||
// Test.
|
||||
await IOUtils.move(srcDir, destDir);
|
||||
const destFile = PathUtils.join(destDir, PathUtils.filename(srcDir), "file.tmp");
|
||||
const destFile = OS.Path.join(destDir, OS.Path.basename(srcDir), "file.tmp");
|
||||
ok(
|
||||
!await IOUtils.exists(srcDir)
|
||||
&& await dirExists(destDir)
|
||||
&& await dirExists(PathUtils.join(destDir, PathUtils.filename(srcDir)))
|
||||
&& await dirExists(OS.Path.join(destDir, OS.Path.basename(srcDir)))
|
||||
&& await fileHasTextContents(destFile, "foo"),
|
||||
"IOUtils::move can move a directory and its contents into another one"
|
||||
)
|
||||
|
@ -159,9 +162,8 @@
|
|||
add_task(async function test_move_failures() {
|
||||
// Set up.
|
||||
info("Test attempt to rename a non-existent source file");
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const notExistsSrc = PathUtils.join(tmpDir, "not_exists_src.tmp");
|
||||
const notExistsDest = PathUtils.join(tmpDir, "not_exists_dest.tmp");
|
||||
const notExistsSrc = OS.Path.join(tmpDir, "not_exists_src.tmp");
|
||||
const notExistsDest = OS.Path.join(tmpDir, "not_exists_dest.tmp");
|
||||
// Test.
|
||||
await Assert.rejects(
|
||||
IOUtils.move(notExistsSrc, notExistsDest),
|
||||
|
@ -175,8 +177,8 @@
|
|||
|
||||
// Set up.
|
||||
info("Test attempt to move a directory to a file");
|
||||
const destFile = PathUtils.join(tmpDir, "test_move_failures_file_dest.tmp");
|
||||
const srcDir = PathUtils.join(tmpDir, "test_move_failure_src.tmp.d");
|
||||
const destFile = OS.Path.join(tmpDir, "test_move_failures_file_dest.tmp");
|
||||
const srcDir = OS.Path.join(tmpDir, "test_move_failure_src.tmp.d");
|
||||
await createFile(destFile);
|
||||
await createDir(srcDir);
|
||||
// Test.
|
||||
|
@ -192,9 +194,8 @@
|
|||
|
||||
add_task(async function test_copy() {
|
||||
// Set up.
|
||||
const tmpDir = PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_orig.tmp");
|
||||
const destFileName = PathUtils.join(tmpDir, "test_ioutils_copy.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_orig.tmp");
|
||||
const destFileName = OS.Path.join(tmpDir, "test_ioutils_copy.tmp");
|
||||
await createFile(tmpFileName, "original");
|
||||
// Test.
|
||||
info("Test copy to new file in same directory");
|
||||
|
@ -236,10 +237,9 @@
|
|||
add_task(async function test_copy_file_to_dir() {
|
||||
// Set up.
|
||||
info("Test copy file to non-existing directory");
|
||||
const tmpDir = PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_copy_file_to_dir.tmp");
|
||||
const destDir = PathUtils.join(tmpDir, "test_copy_file_to_dir.tmp.d");
|
||||
const dest = PathUtils.join(destDir, "dest.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_copy_file_to_dir.tmp");
|
||||
const destDir = OS.Path.join(tmpDir, "test_copy_file_to_dir.tmp.d");
|
||||
const dest = OS.Path.join(destDir, "dest.tmp");
|
||||
await createFile(tmpFileName);
|
||||
// Test.
|
||||
ok(!await IOUtils.exists(destDir), "Expected path not to exist");
|
||||
|
@ -269,7 +269,7 @@
|
|||
ok(await dirExists(destDir), `Expected ${destDir} to be a directory`);
|
||||
ok(
|
||||
await fileExists(tmpFileName)
|
||||
&& await fileExists(PathUtils.join(destDir, PathUtils.filename(tmpFileName))),
|
||||
&& await fileExists(OS.Path.join(destDir, OS.Path.basename(tmpFileName))),
|
||||
"IOUtils::copy can copy a file into an existing dir"
|
||||
);
|
||||
|
||||
|
@ -280,9 +280,8 @@
|
|||
add_task(async function test_copy_dir_recursive() {
|
||||
// Set up.
|
||||
info("Test rename an empty directory");
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const srcDir = PathUtils.join(tmpDir, "test_copy_dir.tmp.d");
|
||||
const destDir = PathUtils.join(tmpDir, "test_copy_dir_dest.tmp.d");
|
||||
const srcDir = OS.Path.join(tmpDir, "test_copy_dir.tmp.d");
|
||||
const destDir = OS.Path.join(tmpDir, "test_copy_dir_dest.tmp.d");
|
||||
await createDir(srcDir);
|
||||
// Test.
|
||||
await IOUtils.copy(srcDir, destDir, { recursive: true });
|
||||
|
@ -294,14 +293,14 @@
|
|||
// Set up.
|
||||
info("Test copy directory and its content into another directory");
|
||||
await createDir(srcDir);
|
||||
await createFile(PathUtils.join(srcDir, "file.tmp"), "foo");
|
||||
await createFile(OS.Path.join(srcDir, "file.tmp"), "foo");
|
||||
// Test.
|
||||
await IOUtils.copy(srcDir, destDir, { recursive: true });
|
||||
const destFile = PathUtils.join(destDir, PathUtils.filename(srcDir), "file.tmp");
|
||||
const destFile = OS.Path.join(destDir, OS.Path.basename(srcDir), "file.tmp");
|
||||
ok(
|
||||
await dirExists(srcDir)
|
||||
&& await dirExists(destDir)
|
||||
&& await dirExists(PathUtils.join(destDir, PathUtils.basename(srcDir)))
|
||||
&& await dirExists(OS.Path.join(destDir, OS.Path.basename(srcDir)))
|
||||
&& await fileHasTextContents(destFile, "foo"),
|
||||
"IOUtils::copy can move a directory and its contents into another one"
|
||||
)
|
||||
|
@ -313,9 +312,8 @@
|
|||
add_task(async function test_copy_failures() {
|
||||
// Set up.
|
||||
info("Test attempt to copy a non-existent source file");
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const notExistsSrc = PathUtils.join(tmpDir, "test_copy_not_exists_src.tmp");
|
||||
const notExistsDest = PathUtils.join(tmpDir, "test_copy_not_exists_dest.tmp");
|
||||
const notExistsSrc = OS.Path.join(tmpDir, "test_copy_not_exists_src.tmp");
|
||||
const notExistsDest = OS.Path.join(tmpDir, "test_copy_not_exists_dest.tmp");
|
||||
// Test.
|
||||
await Assert.rejects(
|
||||
IOUtils.copy(notExistsSrc, notExistsDest),
|
||||
|
@ -329,8 +327,8 @@
|
|||
|
||||
// Set up.
|
||||
info("Test attempt to copy a directory to a file");
|
||||
const destFile = PathUtils.join(tmpDir, "test_copy_failures_file_dest.tmp");
|
||||
const srcDir = PathUtils.join(tmpDir, "test_copy_failure_src.tmp.d");
|
||||
const destFile = OS.Path.join(tmpDir, "test_copy_failures_file_dest.tmp");
|
||||
const srcDir = OS.Path.join(tmpDir, "test_copy_failure_src.tmp.d");
|
||||
await createFile(destFile);
|
||||
await createDir(srcDir);
|
||||
// Test.
|
||||
|
|
|
@ -13,10 +13,12 @@
|
|||
"use strict";
|
||||
|
||||
const { Assert } = ChromeUtils.import("resource://testing-common/Assert.jsm");
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
|
||||
const tmpDir = OS.Constants.Path.tmpDir;
|
||||
|
||||
add_task(async function iterate_dir_failure() {
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
let notExists = PathUtils.join(tmpDir, 'does_not_exist_dir.tmp.d');
|
||||
let notExists = OS.Path.join(tmpDir, 'does_not_exist_dir.tmp.d');
|
||||
|
||||
await Assert.rejects(
|
||||
IOUtils.getChildren(notExists),
|
||||
|
@ -27,7 +29,7 @@
|
|||
|
||||
info('Try to get the children of a regular file');
|
||||
|
||||
let tmpFileName = PathUtils.join(tmpDir, 'iterator_file.tmp');
|
||||
let tmpFileName = OS.Path.join(tmpDir, 'iterator_file.tmp');
|
||||
await createFile(tmpFileName)
|
||||
await Assert.rejects(IOUtils.getChildren(tmpFileName),
|
||||
/Could not get children of file\(.*\) because it is not a directory/,
|
||||
|
@ -40,11 +42,10 @@
|
|||
add_task(async function iterate_dir() {
|
||||
info('Try to get the children of a multi-level directory hierarchy');
|
||||
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
let root = PathUtils.join(tmpDir, 'iterator.tmp.d');
|
||||
let child1 = PathUtils.join(root, 'child1.tmp');
|
||||
let child2 = PathUtils.join(root, 'child2.tmp');
|
||||
let grandchild = PathUtils.join(child1, 'grandchild.tmp');
|
||||
let root = OS.Path.join(tmpDir, 'iterator.tmp.d');
|
||||
let child1 = OS.Path.join(root, 'child1.tmp');
|
||||
let child2 = OS.Path.join(root, 'child2.tmp');
|
||||
let grandchild = OS.Path.join(child1, 'grandchild.tmp');
|
||||
|
||||
await createDir(grandchild); // Ancestors will be created.
|
||||
await createDir(child2);
|
||||
|
@ -60,8 +61,7 @@
|
|||
add_task(async function iterate_empty_dir() {
|
||||
info('Try to get the children of an empty directory');
|
||||
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
let emptyDir = PathUtils.join(tmpDir, 'iterator_empty_dir.tmp.d');
|
||||
let emptyDir = OS.Path.join(tmpDir, 'iterator_empty_dir.tmp.d');
|
||||
await createDir(emptyDir);
|
||||
|
||||
is(
|
||||
|
|
|
@ -15,11 +15,13 @@
|
|||
const { Assert } = ChromeUtils.import("resource://testing-common/Assert.jsm");
|
||||
const { ObjectUtils } = ChromeUtils.import("resource://gre/modules/ObjectUtils.jsm");
|
||||
|
||||
// This is presently only used to test compatability between OS.File and
|
||||
// IOUtils when it comes to writing compressed files. The import and the
|
||||
// test `test_lz4_osfile_compat` can be removed with OS.File is removed.
|
||||
// TODO: Remove this import for OS.File. It is currently being used as a
|
||||
// stop gap for missing IOUtils functionality.
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
|
||||
|
||||
const tmpDir = OS.Constants.Path.tmpDir;
|
||||
|
||||
// This is an impossible sequence of bytes in an UTF-8 encoded file.
|
||||
// See section 3.5.3 of this text:
|
||||
// https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
|
||||
|
@ -27,8 +29,7 @@
|
|||
|
||||
add_task(async function test_read_utf8_failure() {
|
||||
info("Test attempt to read non-existent file (UTF8)");
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const doesNotExist = PathUtils.join(tmpDir, "does_not_exist.tmp");
|
||||
const doesNotExist = OS.Path.join(tmpDir, "does_not_exist.tmp");
|
||||
await Assert.rejects(
|
||||
IOUtils.readUTF8(doesNotExist),
|
||||
/Could not open the file at .*/,
|
||||
|
@ -36,7 +37,7 @@
|
|||
);
|
||||
|
||||
info("Test attempt to read invalid UTF-8");
|
||||
const invalidUTF8File = PathUtils.join(tmpDir, "invalid_utf8.tmp");
|
||||
const invalidUTF8File = OS.Path.join(tmpDir, "invalid_utf8.tmp");
|
||||
|
||||
// Deliberately write the invalid byte sequence to file.
|
||||
await IOUtils.write(invalidUTF8File, invalidUTF8);
|
||||
|
@ -51,9 +52,8 @@
|
|||
});
|
||||
|
||||
add_task(async function test_write_utf8_no_overwrite() {
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
// Make a new file, and try to write to it with overwrites disabled.
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_write_utf8_overwrite.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_write_utf8_overwrite.tmp");
|
||||
const untouchableContents = "Can't touch this!\n";
|
||||
await IOUtils.writeUTF8(tmpFileName, untouchableContents);
|
||||
|
||||
|
@ -90,9 +90,8 @@
|
|||
|
||||
add_task(async function test_write_with_backup() {
|
||||
info("Test backup file option with non-existing file");
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
let fileContents = "Original file contents";
|
||||
let destFileName = PathUtils.join(tmpDir, "test_write_utf8_with_backup_option.tmp");
|
||||
let destFileName = OS.Path.join(tmpDir, "test_write_utf8_with_backup_option.tmp");
|
||||
let backupFileName = destFileName + ".backup";
|
||||
let bytesWritten =
|
||||
await IOUtils.writeUTF8(destFileName, fileContents, {
|
||||
|
@ -138,11 +137,10 @@
|
|||
|
||||
add_task(async function test_write_with_backup_and_tmp() {
|
||||
info("Test backup with tmp and backup file options, non-existing destination");
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
let fileContents = "Original file contents";
|
||||
let destFileName = PathUtils.join(tmpDir, "test_write_utf8_with_backup_and_tmp_options.tmp");
|
||||
let destFileName = OS.Path.join(tmpDir, "test_write_utf8_with_backup_and_tmp_options.tmp");
|
||||
let backupFileName = destFileName + ".backup";
|
||||
let tmpFileName = PathUtils.join(tmpDir, "temp_file.tmp");
|
||||
let tmpFileName = OS.Path.join(tmpDir, "temp_file.tmp");
|
||||
let bytesWritten =
|
||||
await IOUtils.writeUTF8(destFileName, fileContents, {
|
||||
backupFile: backupFileName,
|
||||
|
@ -190,8 +188,7 @@
|
|||
});
|
||||
|
||||
add_task(async function test_empty_read_and_write_utf8() {
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_empty_utf8.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_empty_utf8.tmp");
|
||||
const emptyString = ""
|
||||
const bytesWritten = await IOUtils.writeUTF8(
|
||||
tmpFileName,
|
||||
|
@ -208,8 +205,7 @@
|
|||
add_task(async function test_full_read_and_write_utf8() {
|
||||
// Write a file.
|
||||
info("Test writing emoji file");
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_emoji.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_emoji.tmp");
|
||||
|
||||
// Make sure non-ASCII text is supported for writing and reading back.
|
||||
// For fun, a sampling of space-separated emoji characters from different
|
||||
|
@ -261,8 +257,7 @@
|
|||
|
||||
|
||||
add_task(async function test_utf8_lz4() {
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_utf8_lz4.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_utf8_lz4.tmp");
|
||||
|
||||
info("Test writing lz4 encoded UTF-8 string");
|
||||
const emoji = "☕️ ⚧️ 😀 🖖🏿 🤠 🏳️🌈 🥠 🏴☠️ 🪐";
|
||||
|
@ -298,9 +293,8 @@
|
|||
});
|
||||
|
||||
add_task(async function test_utf8_lz4_osfile_compat() {
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const osfileTmpFile = PathUtils.join(tmpDir, "test_ioutils_utf8_lz4_compat_osfile.tmp");
|
||||
const ioutilsTmpFile = PathUtils.join(tmpDir, "test_ioutils_utf8_lz4_compat_ioutils.tmp");
|
||||
const osfileTmpFile = OS.Path.join(tmpDir, "test_ioutils_utf8_lz4_compat_osfile.tmp");
|
||||
const ioutilsTmpFile = OS.Path.join(tmpDir, "test_ioutils_utf8_lz4_compat_ioutils.tmp");
|
||||
|
||||
info("Test OS.File and IOUtils write the same UTF-8 file with LZ4 compression enabled")
|
||||
const emoji = "☕️ ⚧️ 😀 🖖🏿 🤠 🏳️🌈 🥠 🏴☠️ 🪐";
|
||||
|
@ -322,8 +316,7 @@
|
|||
});
|
||||
|
||||
add_task(async function test_utf8_lz4_bad_call() {
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_utf8_lz4_bad_call.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_utf8_lz4_bad_call.tmp");
|
||||
|
||||
info("readUTF8 ignores the maxBytes option if provided");
|
||||
const emoji = "☕️ ⚧️ 😀 🖖🏿 🤠 🏳️🌈 🥠 🏴☠️ 🪐";
|
||||
|
@ -337,8 +330,7 @@
|
|||
});
|
||||
|
||||
add_task(async function test_utf8_lz4_failure() {
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_utf8_lz4_fail.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_utf8_lz4_fail.tmp");
|
||||
|
||||
info("Test decompression of non-lz4 UTF-8 string");
|
||||
const repeatedBytes = Uint8Array.of(...new Array(50).fill(1));
|
||||
|
|
|
@ -15,10 +15,16 @@
|
|||
const { Assert } = ChromeUtils.import("resource://testing-common/Assert.jsm");
|
||||
const { ObjectUtils } = ChromeUtils.import("resource://gre/modules/ObjectUtils.jsm");
|
||||
|
||||
// TODO: Remove this import for OS.File. It is currently being used as a
|
||||
// stop gap for missing IOUtils functionality.
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
|
||||
|
||||
const tmpDir = OS.Constants.Path.tmpDir;
|
||||
|
||||
add_task(async function test_create_and_remove_file() {
|
||||
info("Test creating and removing a single file");
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutils_create_and_remove.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_create_and_remove.tmp");
|
||||
await IOUtils.write(tmpFileName, new Uint8Array(0));
|
||||
ok(await fileExists(tmpFileName), `Expected file ${tmpFileName} to exist`);
|
||||
|
||||
|
@ -26,7 +32,7 @@
|
|||
ok(!await fileExists(tmpFileName), "IOUtils::remove can remove files");
|
||||
|
||||
info("Test creating and removing an empty directory");
|
||||
const tmpDirName = PathUtils.join(tmpDir, "test_ioutils_create_and_remove.tmp.d");
|
||||
const tmpDirName = OS.Path.join(tmpDir, "test_ioutils_create_and_remove.tmp.d");
|
||||
await IOUtils.makeDirectory(tmpDirName);
|
||||
ok(await dirExists(tmpDirName), `Expected directory ${tmpDirName} to exist`);
|
||||
|
||||
|
@ -35,8 +41,7 @@
|
|||
});
|
||||
|
||||
add_task(async function test_remove_non_existing() {
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpFileName = PathUtils.join(tmpDir, "test_ioutil_remove_non_existing.tmp");
|
||||
const tmpFileName = OS.Path.join(tmpDir, "test_ioutil_remove_non_existing.tmp");
|
||||
ok(!await fileExists(tmpFileName), `Expected file ${tmpFileName} not to exist`);
|
||||
|
||||
await IOUtils.remove(tmpFileName, { ignoreAbsent: true });
|
||||
|
@ -51,11 +56,10 @@
|
|||
});
|
||||
|
||||
add_task(async function test_remove_recursive() {
|
||||
const tmpDir = await PathUtils.getTempDir();
|
||||
const tmpParentDir = PathUtils.join(tmpDir, "test_ioutils_remove.tmp.d");
|
||||
const tmpChildDir = PathUtils.join(tmpParentDir, "child.tmp.d");
|
||||
const tmpTopLevelFileName = PathUtils.join(tmpParentDir, "top.tmp");
|
||||
const tmpNestedFileName = PathUtils.join(tmpChildDir, "nested.tmp");
|
||||
const tmpParentDir = OS.Path.join(tmpDir, "test_ioutils_remove.tmp.d");
|
||||
const tmpChildDir = OS.Path.join(tmpParentDir, "child.tmp.d");
|
||||
const tmpTopLevelFileName = OS.Path.join(tmpParentDir, "top.tmp");
|
||||
const tmpNestedFileName = OS.Path.join(tmpChildDir, "nested.tmp");
|
||||
await createDir(tmpChildDir);
|
||||
await createFile(tmpTopLevelFileName, "");
|
||||
await createFile(tmpNestedFileName, "");
|
||||
|
|
Загрузка…
Ссылка в новой задаче