-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
126 additions
and
85 deletions.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { ObservableProcess } from "./observable-process" | ||
export { Class } from "./class" | ||
export { Result } from "./result" | ||
export { SearchableStream } from "./searchable-stream" | ||
export { start } from "./start" |
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 was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,35 +1,47 @@ | ||
import { strict as assert } from "assert" | ||
|
||
import { startNodeProcess } from "./helpers/start-node-process" | ||
import * as observableProcess from "../src/index" | ||
|
||
suite("ObservableProcess.output") | ||
|
||
test("reading", async function () { | ||
const observable = startNodeProcess('process.stdout.write("hello"); process.stderr.write("world")') | ||
await observable.waitForEnd() | ||
assert.equal(observable.output.fullText(), "helloworld") | ||
const process = observableProcess.start([ | ||
"node", | ||
"-e", | ||
'process.stdout.write("hello"); process.stderr.write("world")', | ||
]) | ||
await process.waitForEnd() | ||
assert.equal(process.output.fullText(), "helloworld") | ||
}) | ||
|
||
test("waiting for text", async function () { | ||
const observable = startNodeProcess('process.stdout.write("hello"); process.stderr.write("world")') | ||
const text = await observable.output.waitForText("helloworld") | ||
const process = observableProcess.start([ | ||
"node", | ||
"-e", | ||
'process.stdout.write("hello"); process.stderr.write("world")', | ||
]) | ||
const text = await process.output.waitForText("helloworld") | ||
assert.equal(text, "helloworld") | ||
}) | ||
|
||
test("waiting for text times out", async function () { | ||
const observable = startNodeProcess("setTimeout(function() {}, 3)") | ||
const promise = observable.output.waitForText("hello", 1) | ||
const process = observableProcess.start(["node", "-e", "setTimeout(function() {}, 3)"]) | ||
const promise = process.output.waitForText("hello", 1) | ||
await assert.rejects(promise, new Error('Text "hello" not found within 1 ms. The captured text so far is:\n')) | ||
}) | ||
|
||
test("waiting for regex", async function () { | ||
const observable = startNodeProcess('process.stdout.write("hello"); process.stderr.write("world")') | ||
const text = await observable.output.waitForRegex(/h.+d/) | ||
const process = observableProcess.start([ | ||
"node", | ||
"-e", | ||
'process.stdout.write("hello"); process.stderr.write("world")', | ||
]) | ||
const text = await process.output.waitForRegex(/h.+d/) | ||
assert.equal(text, "helloworld") | ||
}) | ||
|
||
test("waiting for regex times out", async function () { | ||
const observable = startNodeProcess("setTimeout(function() {}, 3)") | ||
const promise = observable.output.waitForRegex(/h.+d/, 1) | ||
const process = observableProcess.start(["node", "-e", "setTimeout(function() {}, 3)"]) | ||
const promise = process.output.waitForRegex(/h.+d/, 1) | ||
await assert.rejects(promise, new Error("Regex /h.+d/ not found within 1 ms. The captured text so far is:\n")) | ||
}) |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { strict as assert } from "assert" | ||
|
||
import { startNodeProcess } from "./helpers/start-node-process" | ||
import * as observableProcess from "../src/index" | ||
|
||
test("ObservableProcess.pid()", async function () { | ||
const oProcess = startNodeProcess("setTimeout(function() {}, 1)") | ||
const pid = oProcess.pid() | ||
const process = observableProcess.start(["node", "-e", "setTimeout(function() {}, 1)"]) | ||
const pid = process.pid() | ||
assert.equal(typeof pid, "number") | ||
assert.ok(pid > 0) | ||
await oProcess.waitForEnd() | ||
await process.waitForEnd() | ||
}) |
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 |
---|---|---|
@@ -1,35 +1,47 @@ | ||
import { strict as assert } from "assert" | ||
|
||
import { startNodeProcess } from "./helpers/start-node-process" | ||
import * as observableProcess from "../src/index" | ||
|
||
suite("ObservableProcess.stderr") | ||
|
||
test("reading", async function () { | ||
const observable = startNodeProcess('process.stdout.write("hello"); process.stderr.write("world")') | ||
const observable = observableProcess.start([ | ||
"node", | ||
"-e", | ||
'process.stdout.write("hello"); process.stderr.write("world")', | ||
]) | ||
await observable.waitForEnd() | ||
assert.equal(observable.stderr.fullText(), "world") | ||
}) | ||
|
||
test("waiting for text", async function () { | ||
const observable = startNodeProcess('process.stdout.write("hello"); process.stderr.write("world")') | ||
const observable = observableProcess.start([ | ||
"node", | ||
"-e", | ||
'process.stdout.write("hello"); process.stderr.write("world")', | ||
]) | ||
const text = await observable.stderr.waitForText("world") | ||
assert.equal(text, "world") | ||
}) | ||
|
||
test("waiting for text times out", async function () { | ||
const observable = startNodeProcess("setTimeout(function() {}, 10)") | ||
const observable = observableProcess.start(["node", "-e", "setTimeout(function() {}, 10)"]) | ||
const promise = observable.stderr.waitForText("hello", 1) | ||
await assert.rejects(promise, new Error('Text "hello" not found within 1 ms. The captured text so far is:\n')) | ||
}) | ||
|
||
test("waiting for regex", async function () { | ||
const observable = startNodeProcess('process.stdout.write("hello"); process.stderr.write("world")') | ||
const observable = observableProcess.start([ | ||
"node", | ||
"-e", | ||
'process.stdout.write("hello"); process.stderr.write("world")', | ||
]) | ||
const text = await observable.stderr.waitForRegex(/w.+d/) | ||
assert.equal(text, "world") | ||
}) | ||
|
||
test("waiting for regex times out", async function () { | ||
const observable = startNodeProcess("setTimeout(function() {}, 10)") | ||
const observable = observableProcess.start(["node", "-e", "setTimeout(function() {}, 10)"]) | ||
const promise = observable.stderr.waitForRegex(/w.+d/, 1) | ||
await assert.rejects(promise, new Error("Regex /w.+d/ not found within 1 ms. The captured text so far is:\n")) | ||
}) |
Oops, something went wrong.