зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1338263 - Remove remaining legacy generator from toolkit/components/osfile/tests/xpcshell/. r=Yoric
This commit is contained in:
Родитель
014382051d
Коммит
63b579c075
|
@ -20,7 +20,7 @@ function run_test() {
|
|||
/**
|
||||
* Test OS.File.getAvailableFreeSpace
|
||||
*/
|
||||
add_task(function() {
|
||||
add_task(function*() {
|
||||
// Set up profile. We will use profile path to query for available free
|
||||
// space.
|
||||
do_get_profile();
|
||||
|
|
|
@ -10,7 +10,7 @@ function run_test() {
|
|||
run_next_test();
|
||||
}
|
||||
|
||||
add_task(function test_compress_lz4() {
|
||||
add_task(function* test_compress_lz4() {
|
||||
let path = OS.Path.join(OS.Constants.Path.tmpDir, "compression.lz");
|
||||
let length = 1024;
|
||||
let array = new Uint8Array(length);
|
||||
|
@ -29,7 +29,7 @@ add_task(function test_compress_lz4() {
|
|||
do_check_eq(arrayAsString, Array.prototype.join.call(decompressed));
|
||||
});
|
||||
|
||||
add_task(function test_uncompressed() {
|
||||
add_task(function* test_uncompressed() {
|
||||
do_print("Writing data without compression");
|
||||
let path = OS.Path.join(OS.Constants.Path.tmpDir, "no_compression.tmp");
|
||||
let array = new Uint8Array(1024);
|
||||
|
@ -50,7 +50,7 @@ add_task(function test_uncompressed() {
|
|||
do_check_true(exn.message.indexOf(`Invalid header (no magic number) - Data: ${ path }`) != -1);
|
||||
});
|
||||
|
||||
add_task(function test_no_header() {
|
||||
add_task(function* test_no_header() {
|
||||
let path = OS.Path.join(OS.Constants.Path.tmpDir, "no_header.tmp");
|
||||
let array = new Uint8Array(8).fill(0,0); // Small array with no header
|
||||
|
||||
|
@ -69,7 +69,7 @@ add_task(function test_no_header() {
|
|||
do_check_true(exn.message.indexOf(`Buffer is too short (no header) - Data: ${ path }`) != -1);
|
||||
});
|
||||
|
||||
add_task(function test_invalid_content() {
|
||||
add_task(function* test_invalid_content() {
|
||||
let path = OS.Path.join(OS.Constants.Path.tmpDir, "invalid_content.tmp");
|
||||
let arr1 = new Uint8Array([109, 111, 122, 76, 122, 52, 48, 0]);
|
||||
let arr2 = new Uint8Array(248).fill(1,0);
|
||||
|
@ -95,4 +95,4 @@ add_task(function test_invalid_content() {
|
|||
|
||||
add_task(function() {
|
||||
do_test_finished();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,7 +9,7 @@ function run_test() {
|
|||
* Test to ensure that deprecation warning is issued on use
|
||||
* of creationDate.
|
||||
*/
|
||||
add_task(function test_deprecatedCreationDate () {
|
||||
add_task(function* test_deprecatedCreationDate () {
|
||||
let deferred = Promise.defer();
|
||||
let consoleListener = {
|
||||
observe: function (aMessage) {
|
||||
|
|
|
@ -12,7 +12,7 @@ var EXISTING_FILE = do_get_file("xpcshell.ini").path;
|
|||
|
||||
// Tests on |open|
|
||||
|
||||
add_test_pair(function test_typeerror() {
|
||||
add_test_pair(function* test_typeerror() {
|
||||
let exn;
|
||||
try {
|
||||
let fd = yield OS.File.open("/tmp", {no_such_key: 1});
|
||||
|
|
|
@ -78,7 +78,7 @@ add_task(function* test_root() {
|
|||
/**
|
||||
* Creating subdirectories
|
||||
*/
|
||||
add_task(function test_option_from() {
|
||||
add_task(function* test_option_from() {
|
||||
let dir = Path.join(profileDir, "a", "b", "c");
|
||||
|
||||
// Sanity checking for the test
|
||||
|
|
|
@ -15,7 +15,7 @@ function run_test() {
|
|||
* - with a non-existing file (should fail);
|
||||
* - with inconsistent arguments (should fail).
|
||||
*/
|
||||
add_task(function() {
|
||||
add_task(function*() {
|
||||
// Attempt to open a file that does not exist, ensure that it yields the
|
||||
// appropriate error.
|
||||
try {
|
||||
|
@ -55,7 +55,7 @@ add_task(function() {
|
|||
* Test the error thrown by OS.File.open when attempting to open a directory
|
||||
* that does not exist.
|
||||
*/
|
||||
add_task(function test_error_attributes () {
|
||||
add_task(function* test_error_attributes () {
|
||||
|
||||
let dir = OS.Path.join(do_get_profile().path, "test_osfileErrorAttrs");
|
||||
let fpath = OS.Path.join(dir, "test_error_attributes.txt");
|
||||
|
|
|
@ -23,7 +23,7 @@ function setup_mode(mode) {
|
|||
}
|
||||
|
||||
// Test append mode.
|
||||
function test_append(mode) {
|
||||
function* test_append(mode) {
|
||||
let path = OS.Path.join(OS.Constants.Path.tmpDir,
|
||||
"test_osfile_async_append.tmp");
|
||||
|
||||
|
@ -64,7 +64,7 @@ function test_append(mode) {
|
|||
}
|
||||
|
||||
// Test no-append mode.
|
||||
function test_no_append(mode) {
|
||||
function* test_no_append(mode) {
|
||||
let path = OS.Path.join(OS.Constants.Path.tmpDir,
|
||||
"test_osfile_async_noappend.tmp");
|
||||
|
||||
|
|
|
@ -64,9 +64,9 @@ var reference_fetch_file = function reference_fetch_file(path) {
|
|||
*
|
||||
* @resolves {null}
|
||||
*/
|
||||
var reference_compare_files = function reference_compare_files(a, b) {
|
||||
let a_contents = yield reference_fetch_file(a);
|
||||
let b_contents = yield reference_fetch_file(b);
|
||||
var reference_compare_files = async function reference_compare_files(a, b) {
|
||||
let a_contents = await reference_fetch_file(a);
|
||||
let b_contents = await reference_fetch_file(b);
|
||||
// Not using do_check_eq to avoid dumping the whole file to the log.
|
||||
// It is OK to === compare here, as both variables contain a string.
|
||||
do_check_true(a_contents === b_contents);
|
||||
|
@ -75,7 +75,7 @@ var reference_compare_files = function reference_compare_files(a, b) {
|
|||
/**
|
||||
* Test to ensure that OS.File.copy works.
|
||||
*/
|
||||
function test_copymove(options = {}) {
|
||||
function* test_copymove(options = {}) {
|
||||
let source = OS.Path.join((yield OS.File.getCurrentDirectory()),
|
||||
EXISTING_FILE);
|
||||
let dest = OS.Path.join(OS.Constants.Path.tmpDir,
|
||||
|
|
|
@ -12,7 +12,7 @@ function run_test() {
|
|||
* Test to ensure that |File.prototype.flush| is available in the async API.
|
||||
*/
|
||||
|
||||
add_task(function test_flush() {
|
||||
add_task(function* test_flush() {
|
||||
let path = OS.Path.join(OS.Constants.Path.tmpDir,
|
||||
"test_osfile_async_flush.tmp");
|
||||
let file = yield OS.File.open(path, {trunc: true, write: true});
|
||||
|
|
|
@ -13,7 +13,7 @@ Components.utils.import("resource://gre/modules/Task.jsm");
|
|||
*/
|
||||
|
||||
// Test setPosition/getPosition.
|
||||
function test_setPosition(forward, current, backward) {
|
||||
function* test_setPosition(forward, current, backward) {
|
||||
let path = OS.Path.join(OS.Constants.Path.tmpDir,
|
||||
"test_osfile_async_largefiles.tmp");
|
||||
|
||||
|
@ -62,7 +62,7 @@ function test_setPosition(forward, current, backward) {
|
|||
}
|
||||
|
||||
// Test setPosition/getPosition expected failures.
|
||||
function test_setPosition_failures() {
|
||||
function* test_setPosition_failures() {
|
||||
let path = OS.Path.join(OS.Constants.Path.tmpDir,
|
||||
"test_osfile_async_largefiles.tmp");
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ function run_test() {
|
|||
run_next_test();
|
||||
}
|
||||
|
||||
add_task(function test_closed() {
|
||||
add_task(function* test_closed() {
|
||||
OS.Shared.DEBUG = true;
|
||||
let currentDir = yield OS.File.getCurrentDirectory();
|
||||
do_print("Open a file, ensure that we can call stat()");
|
||||
|
|
|
@ -19,19 +19,17 @@ Components.utils.import("resource://gre/modules/Task.jsm");
|
|||
* test_backupTo_option_with_backup_file.tmp
|
||||
* test_backupTo_option_with_backup_file.tmp.backup
|
||||
*/
|
||||
function clearFiles() {
|
||||
return Task.spawn(function () {
|
||||
let files = ["test_backupTo_option_with_tmpPath.tmp",
|
||||
"test_backupTo_option_without_tmpPath.tmp",
|
||||
"test_non_backupTo_option.tmp",
|
||||
"test_backupTo_option_without_destination_file.tmp",
|
||||
"test_backupTo_option_with_backup_file.tmp"];
|
||||
for (let file of files) {
|
||||
let path = Path.join(Constants.Path.tmpDir, file);
|
||||
yield File.remove(path);
|
||||
yield File.remove(path + ".backup");
|
||||
}
|
||||
});
|
||||
async function clearFiles() {
|
||||
let files = ["test_backupTo_option_with_tmpPath.tmp",
|
||||
"test_backupTo_option_without_tmpPath.tmp",
|
||||
"test_non_backupTo_option.tmp",
|
||||
"test_backupTo_option_without_destination_file.tmp",
|
||||
"test_backupTo_option_with_backup_file.tmp"];
|
||||
for (let file of files) {
|
||||
let path = Path.join(Constants.Path.tmpDir, file);
|
||||
await File.remove(path);
|
||||
await File.remove(path + ".backup");
|
||||
}
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
|
|
|
@ -18,7 +18,7 @@ function run_test() {
|
|||
run_next_test();
|
||||
}
|
||||
|
||||
add_task(function() {
|
||||
add_task(function*() {
|
||||
// Set up profile. We create the directory in the profile, because the profile
|
||||
// is removed after every test run.
|
||||
do_get_profile();
|
||||
|
|
|
@ -20,7 +20,7 @@ function run_test() {
|
|||
/**
|
||||
* Test OS.File.removeEmptyDir
|
||||
*/
|
||||
add_task(function() {
|
||||
add_task(function*() {
|
||||
// Set up profile. We create the directory in the profile, because the profile
|
||||
// is removed after every test run.
|
||||
do_get_profile();
|
||||
|
|
|
@ -10,14 +10,14 @@ add_task(function init() {
|
|||
/**
|
||||
* Test logging of file descriptors leaks.
|
||||
*/
|
||||
add_task(function system_shutdown() {
|
||||
add_task(function* system_shutdown() {
|
||||
|
||||
// Test that unclosed files cause warnings
|
||||
// Test that unclosed directories cause warnings
|
||||
// Test that closed files do not cause warnings
|
||||
// Test that closed directories do not cause warnings
|
||||
function testLeaksOf(resource, topic) {
|
||||
return Task.spawn(function() {
|
||||
return Task.spawn(function*() {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
// Register observer
|
||||
|
@ -69,7 +69,7 @@ add_task(function system_shutdown() {
|
|||
Services.prefs.clearUserPref("toolkit.osfile.test.shutdown.observer");
|
||||
Services.prefs.clearUserPref("toolkit.async_shutdown.testing");
|
||||
|
||||
throw new Task.Result(resolved);
|
||||
return resolved;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ function run_test() {
|
|||
}
|
||||
|
||||
function testFiles(filename) {
|
||||
return Task.spawn(function() {
|
||||
return Task.spawn(function*() {
|
||||
const MAX_TRIES = 10;
|
||||
let profileDir = OS.Constants.Path.profileDir;
|
||||
let path = OS.Path.join(profileDir, filename);
|
||||
|
@ -79,7 +79,7 @@ function testFiles(filename) {
|
|||
});
|
||||
}
|
||||
|
||||
add_task(function test_unique() {
|
||||
add_task(function* test_unique() {
|
||||
OS.Shared.DEBUG = true;
|
||||
// Tests files with extension
|
||||
yield testFiles("dummy_unique_file.txt");
|
||||
|
|
Загрузка…
Ссылка в новой задаче