From 3eaf0fe82b127d7a9664df1d864f07933a1195fd Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 29 Sep 2014 16:41:49 +0800 Subject: [PATCH] spec: asar: child_process.fork --- spec/asar-spec.coffee | 21 ++++++++++++++++++--- spec/fixtures/asar/a.asar | Bin 648 -> 778 bytes 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/spec/asar-spec.coffee b/spec/asar-spec.coffee index 112d4a02..e1286f93 100644 --- a/spec/asar-spec.coffee +++ b/spec/asar-spec.coffee @@ -162,7 +162,7 @@ describe 'asar package', -> it 'throws ENOENT error when can not find file', (done) -> p = path.join fixtures, 'asar', 'a.asar', 'file4' - fs.lstat p, (err, stats) -> + stats = fs.lstat p, (err, stats) -> assert.equal err.code, 'ENOENT' done() @@ -170,7 +170,7 @@ describe 'asar package', -> it 'reads dirs from root', -> p = path.join fixtures, 'asar', 'a.asar' dirs = fs.readdirSync p - assert.deepEqual dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2'] + assert.deepEqual dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js'] it 'reads dirs from a normal dir', -> p = path.join fixtures, 'asar', 'a.asar', 'dir1' @@ -192,7 +192,7 @@ describe 'asar package', -> p = path.join fixtures, 'asar', 'a.asar' dirs = fs.readdir p, (err, dirs) -> assert.equal err, null - assert.deepEqual dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2'] + assert.deepEqual dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js'] done() it 'reads dirs from a normal dir', (done) -> @@ -246,3 +246,18 @@ describe 'asar package', -> fs.open p, (err, stats) -> assert.equal err.code, 'ENOENT' done() + + describe 'child_process.fork', -> + child_process = require 'child_process' + + it 'opens a normal js file', (done) -> + child = child_process.fork path.join(fixtures, 'asar', 'a.asar', 'ping.js') + child.on 'message', (msg) -> + assert.equal msg, 'message' + done() + child.send 'message' + + it 'throws ENOENT error when can not find file', -> + p = path.join fixtures, 'asar', 'a.asar', 'not-exist' + throws = -> child_process.fork p + assert.throws throws, /ENOENT/ diff --git a/spec/fixtures/asar/a.asar b/spec/fixtures/asar/a.asar index 7f04d34f60401ae747f5aa29cf72e09e65227d53..0b74f5639cd8a5eee06fb7d8dcb9e58b6f5fa7a5 100644 GIT binary patch delta 240 zcmeBR?PB9)VPIg$U}9iM0pi$+yw*$x1{3$oGaDM1O?&{P42>ps8v!W`u%M9%SkTyD zG9zO$qv6E8ia_F?B8Q=gg;H&8ttN+&VPIgeU}9h}0b+xRyw(#BDKHtCOzvltXEHXJ*k?33n^AFcFQX!piN$1g z#$+Z_lgYV2IWq&05>_)arP|ubd5m%_21>O$ll>TFCVyfK<*ltv%gjkN;sTL|lRq*^ KPX56p1i}FG1|F0E -- 2.43.0