-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for running workers in terminal apps (#427)
* Add tests for running workers in terminal apps * Use a separate runner instead of harness and use new helper methods * Remove unnecessary package.json fields * Use simpler workers * Add test for passing passing args to worker * Update wrong name in package.json * Switch worker runner to use args * Cleanup unused message argument
- Loading branch information
1 parent
2409eb8
commit 13758e4
Showing
8 changed files
with
125 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const pipe = Pear.worker.pipe() | ||
pipe.on('data', () => { | ||
try { | ||
pipe.write('hello world') | ||
} catch (err) { | ||
console.error(err) | ||
Pear.exit() | ||
} | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "hello-world", | ||
"main": "index.js", | ||
"pear": { | ||
"name": "hello-world", | ||
"type": "terminal" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const pipe = Pear.worker.pipe() | ||
pipe.on('data', () => { | ||
try { | ||
pipe.write(JSON.stringify(Pear.config.args)) | ||
} catch (err) { | ||
console.error(err) | ||
Pear.exit() | ||
} | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "print-args", | ||
"main": "index.js", | ||
"pear": { | ||
"name": "print-args", | ||
"type": "terminal" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const pipe = Pear.worker.pipe() | ||
|
||
const [workerPath] = Pear.config.args | ||
const workerPipe = Pear.worker.run(workerPath) | ||
workerPipe.on('data', (data) => { | ||
pipe.write(data) | ||
workerPipe.end() | ||
}) | ||
|
||
workerPipe.write('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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "worker-runner", | ||
"main": "index.js", | ||
"pear": { | ||
"name": "worker-runner", | ||
"type": "terminal" | ||
} | ||
} |
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