diff --git a/test/03-worker.test.js b/test/03-worker.test.js index 8c8467ff8..03d3ca4a3 100644 --- a/test/03-worker.test.js +++ b/test/03-worker.test.js @@ -15,10 +15,6 @@ const workerDestroyFromChild = path.join(Helper.localDir, 'test', 'fixtures', 'w const workerEndFromParent = path.join(Helper.localDir, 'test', 'fixtures', 'worker-end-from-parent') const workerDestroyFromParent = path.join(Helper.localDir, 'test', 'fixtures', 'worker-destroy-from-parent') -const workerParentDesktop = path.join(Helper.localDir, 'test', 'fixtures', 'worker-parent-desktop') -const workerEndFromParentDesktop = path.join(Helper.localDir, 'test', 'fixtures', 'worker-end-from-parent-desktop') -const workerDestroyFromParentDesktop = path.join(Helper.localDir, 'test', 'fixtures', 'worker-destroy-from-parent-desktop') - test('worker pipe', async function ({ is, plan, teardown }) { plan(1) const helper = new Helper() @@ -134,27 +130,3 @@ test('[terminal] worker exit when parent calls pipe.destroy()', async function ( const { pipe } = await Helper.run({ link: workerDestroyFromParent, args: [workerChild] }) await Helper.untilWorkerExit(pipe) }) - -// -// test worker exit gracefully for desktop app -// - -test('[desktop] worker exit when child calls pipe.end()', async function () { - const { pipe } = await Helper.run({ link: workerParentDesktop, args: [workerEndFromChild] }) - await Helper.untilWorkerExit(pipe) -}) - -test('[desktop] worker exit when child calls pipe.destroy()', async function () { - const { pipe } = await Helper.run({ link: workerParentDesktop, args: [workerDestroyFromChild] }) - await Helper.untilWorkerExit(pipe) -}) - -test('[desktop] worker exit when parent calls pipe.end()', async function () { - const { pipe } = await Helper.run({ link: workerEndFromParentDesktop, args: [workerChild] }) - await Helper.untilWorkerExit(pipe) -}) - -test('[desktop] worker exit when parent calls pipe.destroy()', async function () { - const { pipe } = await Helper.run({ link: workerDestroyFromParentDesktop, args: [workerChild] }) - await Helper.untilWorkerExit(pipe) -}) diff --git a/test/fixtures/worker-destroy-from-parent-desktop/app.js b/test/fixtures/worker-destroy-from-parent-desktop/app.js deleted file mode 100644 index fb22b5e91..000000000 --- a/test/fixtures/worker-destroy-from-parent-desktop/app.js +++ /dev/null @@ -1,23 +0,0 @@ -const link = Pear.config.args[Pear.config.args.length - 1] -const pipe = Pear.worker.run(link) -pipe.resume() -await new Promise((resolve) => setTimeout(resolve, 1000)) -pipe.destroy() -await untilExit(pipe) -Pear.Window.self.close() - -async function untilExit (pipe, timeout = 5000) { - const start = Date.now() - while (isRunning(pipe)) { - if (Date.now() - start > timeout) throw new Error('timed out') - await new Promise((resolve) => setTimeout(resolve, 100)) - } -} - -function isRunning (pipe) { - try { - return process.kill(pipe.pid, 0) - } catch (err) { - return err.code === 'EPERM' - } -} diff --git a/test/fixtures/worker-destroy-from-parent-desktop/index.html b/test/fixtures/worker-destroy-from-parent-desktop/index.html deleted file mode 100644 index 91a294a71..000000000 --- a/test/fixtures/worker-destroy-from-parent-desktop/index.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/test/fixtures/worker-destroy-from-parent-desktop/package.json b/test/fixtures/worker-destroy-from-parent-desktop/package.json deleted file mode 100644 index 5abd6a4ee..000000000 --- a/test/fixtures/worker-destroy-from-parent-desktop/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "worker-destroy-from-parent-desktop", - "main": "index.html", - "type": "module", - "pear": {} -} diff --git a/test/fixtures/worker-end-from-parent-desktop/app.js b/test/fixtures/worker-end-from-parent-desktop/app.js deleted file mode 100644 index 5782bd3c1..000000000 --- a/test/fixtures/worker-end-from-parent-desktop/app.js +++ /dev/null @@ -1,23 +0,0 @@ -const link = Pear.config.args[Pear.config.args.length - 1] -const pipe = Pear.worker.run(link) -pipe.resume() -await new Promise((resolve) => setTimeout(resolve, 1000)) -pipe.end() -await untilExit(pipe) -Pear.Window.self.close() - -async function untilExit (pipe, timeout = 5000) { - const start = Date.now() - while (isRunning(pipe)) { - if (Date.now() - start > timeout) throw new Error('timed out') - await new Promise((resolve) => setTimeout(resolve, 100)) - } -} - -function isRunning (pipe) { - try { - return process.kill(pipe.pid, 0) - } catch (err) { - return err.code === 'EPERM' - } -} diff --git a/test/fixtures/worker-end-from-parent-desktop/index.html b/test/fixtures/worker-end-from-parent-desktop/index.html deleted file mode 100644 index 91a294a71..000000000 --- a/test/fixtures/worker-end-from-parent-desktop/index.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/test/fixtures/worker-end-from-parent-desktop/package.json b/test/fixtures/worker-end-from-parent-desktop/package.json deleted file mode 100644 index bb61de6d0..000000000 --- a/test/fixtures/worker-end-from-parent-desktop/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "worker-end-from-parent-desktop", - "main": "index.html", - "type": "module", - "pear": {} -} diff --git a/test/fixtures/worker-parent-desktop/app.js b/test/fixtures/worker-parent-desktop/app.js deleted file mode 100644 index 1589e0bfc..000000000 --- a/test/fixtures/worker-parent-desktop/app.js +++ /dev/null @@ -1,21 +0,0 @@ -const link = Pear.config.args[Pear.config.args.length - 1] -const pipe = Pear.worker.run(link) -pipe.resume() -await untilExit(pipe) -Pear.Window.self.close() - -async function untilExit (pipe, timeout = 5000) { - const start = Date.now() - while (isRunning(pipe)) { - if (Date.now() - start > timeout) throw new Error('timed out') - await new Promise((resolve) => setTimeout(resolve, 100)) - } -} - -function isRunning (pipe) { - try { - return process.kill(pipe.pid, 0) - } catch (err) { - return err.code === 'EPERM' - } -} diff --git a/test/fixtures/worker-parent-desktop/index.html b/test/fixtures/worker-parent-desktop/index.html deleted file mode 100644 index 91a294a71..000000000 --- a/test/fixtures/worker-parent-desktop/index.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/test/fixtures/worker-parent-desktop/package.json b/test/fixtures/worker-parent-desktop/package.json deleted file mode 100644 index f08d57e18..000000000 --- a/test/fixtures/worker-parent-desktop/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "worker-parent-desktop", - "main": "index.html", - "type": "module", - "pear": {} -}