Browse Source

Add specs for ELECTRON_NO_ASAR env var

Kevin Sawicki 8 years ago
parent
commit
8897a7a926
2 changed files with 50 additions and 0 deletions
  1. 35 0
      spec/asar-spec.js
  2. 15 0
      spec/fixtures/module/no-asar.js

+ 35 - 0
spec/asar-spec.js

@@ -753,6 +753,41 @@ describe('asar package', function () {
         assert.equal(process.noAsar, false)
       })
     })
+
+    describe('process.env.ELECTRON_NO_ASAR', function () {
+      it('disables asar support in forked processes', function (done) {
+        const forked = ChildProcess.fork(path.join(__dirname, 'fixtures', 'module', 'no-asar.js'), [], {
+          env: {
+            ELECTRON_NO_ASAR: true
+          }
+        })
+        forked.on('message', function (stats) {
+          assert.equal(stats.isFile, true)
+          assert.equal(stats.size, 778)
+          done()
+        })
+      })
+
+      it('disables asar support in spawned processes', function (done) {
+        const spawned = ChildProcess.spawn(process.execPath, [path.join(__dirname, 'fixtures', 'module', 'no-asar.js')], {
+          env: {
+            ELECTRON_NO_ASAR: true,
+            ELECTRON_RUN_AS_NODE: true
+          }
+        })
+
+        let output = ''
+        spawned.stdout.on('data', function (data) {
+          output += data
+        })
+        spawned.stdout.on('close', function () {
+          stats = JSON.parse(output)
+          assert.equal(stats.isFile, true)
+          assert.equal(stats.size, 778)
+          done()
+        })
+      })
+    })
   })
 
   describe('asar protocol', function () {

+ 15 - 0
spec/fixtures/module/no-asar.js

@@ -0,0 +1,15 @@
+const fs = require('fs')
+const path = require('path')
+
+const stats = fs.statSync(path.join(__dirname, '..', 'asar', 'a.asar'))
+
+const details = {
+  isFile: stats.isFile(),
+  size: stats.size
+}
+
+if (process.send != null) {
+  process.send(details)
+} else {
+  console.log(JSON.stringify(details))
+}