forked from mirrors/gecko-dev
There's a lot of history in this area that mostly explains why this has not been supported in the past, leading to several awkward workarounds in tests. But it doesn't appear that there's any reason to prevent tests from creating actual command lines, so that's what we allow here. I've elected to flesh out `Cu.createCommandLine` rather than expose `.init(..._)` directly since `Cu.createCommandLine` is already used in the relevant tests and is only used in tests. And I've made the arguments required, rather than optional, so that consumers think about the arguments, in particular `state`. Differential Revision: https://phabricator.services.mozilla.com/D132089
36 lines
1 KiB
JavaScript
36 lines
1 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
add_task(async function test_resolveFile() {
|
|
const EXISTING_FILE = do_get_file("xpcshell.ini");
|
|
// We explicitly do not initialize this with a working dir.
|
|
let cmdLine = Cu.createCommandLine(
|
|
[],
|
|
null,
|
|
Ci.nsICommandLine.STATE_REMOTE_EXPLICIT
|
|
);
|
|
let fileByPath = cmdLine.resolveFile(EXISTING_FILE.path);
|
|
info("Resolved: " + fileByPath.path);
|
|
Assert.ok(EXISTING_FILE.equals(fileByPath), "Should find the same file");
|
|
|
|
Assert.ok(
|
|
!cmdLine.resolveFile("xpcshell.ini"),
|
|
"Should get null for relative files."
|
|
);
|
|
|
|
// Now create a commandline with a working dir:
|
|
cmdLine = Cu.createCommandLine(
|
|
[],
|
|
EXISTING_FILE.parent,
|
|
Ci.nsICommandLine.STATE_REMOTE_EXPLICIT
|
|
);
|
|
let resolvedTxtFile = cmdLine.resolveFile("xpcshell.ini");
|
|
|
|
info("Resolved: " + resolvedTxtFile.path);
|
|
Assert.ok(
|
|
EXISTING_FILE.equals(resolvedTxtFile),
|
|
"Should resolve relative file."
|
|
);
|
|
});
|