-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch from Deno.run to Deno.Command #50
Open
shapirone
wants to merge
1
commit into
main
Choose a base branch
from
neil-remove-run
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,6 @@ const fakeManifest = (...domains: string[]) => { | |
}; | ||
}; | ||
|
||
const FAKE_DENO_PATH = "/path/to/deno"; | ||
|
||
const FAKE_DENO_LAND_MODULE = | ||
"https://deno.land/x/[email protected]/local-run.ts"; | ||
const FAKE_DENO_LAND_EXPECTED_MODULE = | ||
|
@@ -31,13 +29,11 @@ Deno.test("getCommandline function", async (t) => { | |
await t.step("issues right command no dev domain", () => { | ||
const command = getCommandline( | ||
FAKE_DENO_LAND_MODULE, | ||
FAKE_DENO_PATH, | ||
fakeManifest("example.com"), | ||
"", | ||
MockProtocol(), | ||
); | ||
assertEquals(command, [ | ||
FAKE_DENO_PATH, | ||
"run", | ||
"-q", | ||
"--config=deno.jsonc", | ||
|
@@ -51,13 +47,11 @@ Deno.test("getCommandline function", async (t) => { | |
await t.step("issues right command with dev domain", () => { | ||
const command = getCommandline( | ||
FAKE_DENO_LAND_MODULE, | ||
FAKE_DENO_PATH, | ||
fakeManifest("example.com"), | ||
"dev1234.slack.com", | ||
MockProtocol(), | ||
); | ||
assertEquals(command, [ | ||
FAKE_DENO_PATH, | ||
"run", | ||
"-q", | ||
"--config=deno.jsonc", | ||
|
@@ -72,13 +66,11 @@ Deno.test("getCommandline function", async (t) => { | |
await t.step("issues right command with no outgoing domains", () => { | ||
const command = getCommandline( | ||
FAKE_DENO_LAND_MODULE, | ||
FAKE_DENO_PATH, | ||
fakeManifest(), | ||
"", | ||
MockProtocol(), | ||
); | ||
assertEquals(command, [ | ||
FAKE_DENO_PATH, | ||
"run", | ||
"-q", | ||
"--config=deno.jsonc", | ||
|
@@ -92,13 +84,11 @@ Deno.test("getCommandline function", async (t) => { | |
await t.step("issues right command with a local file module", () => { | ||
const command = getCommandline( | ||
FAKE_FILE_MODULE, | ||
FAKE_DENO_PATH, | ||
fakeManifest(), | ||
"", | ||
MockProtocol(), | ||
); | ||
assertEquals(command, [ | ||
FAKE_DENO_PATH, | ||
"run", | ||
"-q", | ||
"--config=deno.jsonc", | ||
|
@@ -112,13 +102,11 @@ Deno.test("getCommandline function", async (t) => { | |
await t.step("handles root paths", () => { | ||
const command = getCommandline( | ||
"file:///local-run.ts", | ||
FAKE_DENO_PATH, | ||
fakeManifest("example.com"), | ||
"", | ||
MockProtocol(), | ||
); | ||
assertEquals(command, [ | ||
FAKE_DENO_PATH, | ||
"run", | ||
"-q", | ||
"--config=deno.jsonc", | ||
|
@@ -134,13 +122,11 @@ Deno.test("getCommandline function", async (t) => { | |
protocol.getCLIFlags = () => ["--mycustomflag"]; | ||
const command = getCommandline( | ||
"file:///local-run.ts", | ||
FAKE_DENO_PATH, | ||
fakeManifest("example.com"), | ||
"", | ||
protocol, | ||
); | ||
assertEquals(command, [ | ||
FAKE_DENO_PATH, | ||
"run", | ||
"-q", | ||
"--config=deno.jsonc", | ||
|
@@ -188,22 +174,22 @@ Deno.test("runWithOutgoingDomains function", async (t) => { | |
const execPathSpy = mock.stub(Deno, "execPath", () => { | ||
throw new Error("no idea where that is"); | ||
}); | ||
const runStub = mock.stub( | ||
const commandStub = mock.stub( | ||
Deno, | ||
"run", | ||
"Command", | ||
() => ({ | ||
status: () => | ||
Promise.resolve({ | ||
success: true, | ||
code: 0, | ||
}), | ||
} as unknown as Deno.Process<Deno.RunOptions>), | ||
spawn: () => { | ||
return { | ||
status: Promise.resolve({ success: true, code: 0 }), | ||
} as unknown as Deno.ChildProcess; | ||
}, | ||
} as Deno.Command), | ||
); | ||
try { | ||
await runWithOutgoingDomains(createEmptyManifest, "", protocol); | ||
} finally { | ||
execPathSpy.restore(); | ||
runStub.restore(); | ||
commandStub.restore(); | ||
} | ||
mock.assertSpyCallArg( | ||
errorSpy, | ||
|
@@ -230,21 +216,21 @@ Deno.test("runWithOutgoingDomains function", async (t) => { | |
exitSpy as unknown as () => never, | ||
); | ||
const exitCode = 1337; | ||
const runStub = mock.stub( | ||
const commandStub = mock.stub( | ||
Deno, | ||
"run", | ||
"Command", | ||
() => ({ | ||
status: () => | ||
Promise.resolve({ | ||
success: false, | ||
code: exitCode, | ||
}), | ||
} as unknown as Deno.Process<Deno.RunOptions>), | ||
spawn: () => { | ||
return { | ||
status: Promise.resolve({ success: false, code: exitCode }), | ||
} as unknown as Deno.ChildProcess; | ||
}, | ||
} as Deno.Command), | ||
); | ||
try { | ||
await runWithOutgoingDomains(createEmptyManifest, "", protocol); | ||
} finally { | ||
runStub.restore(); | ||
commandStub.restore(); | ||
exitStub.restore(); | ||
} | ||
mock.assertSpyCallArg( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we should test around this is whether or not this leaves the process open or if we should close via something like
subprocess.kill()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, once the status code from a process is able to be retrieved, this implies that the process completed, so my expectation is that we don't need to do that - but doesn't hurt!