| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6df3e31 commit a4f5052
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const common = require('../common'); | |
| 4 | 4 | const fixtures = require('../common/fixtures'); | |
| 5 | + const tmpdir = require('../common/tmpdir'); | ||
| 5 | 6 | ||
| 6 | 7 | const { readFileSync } = require('fs'); | |
| 7 | 8 | const { | |
@@ -43,6 +44,14 @@ function skipIfSingleExecutableIsNotSupported() { | |||
| 43 | 44 | common.skip('On s390x, postject fails with `memory access out of bounds`.'); | |
| 44 | 45 | } | |
| 45 | 46 | } | |
| 47 | + | ||
| 48 | + tmpdir.refresh(); | ||
| 49 | + | ||
| 50 | + // The SEA tests involve making a copy of the executable and writing some fixtures | ||
| 51 | + // to the tmpdir. To be safe, ensure that at least 120MB disk space is available. | ||
| 52 | + if (!tmpdir.hasEnoughSpace(120 * 1024 * 1024)) { | ||
| 53 | + common.skip('Available disk space < 120MB'); | ||
| 54 | + } | ||
| 46 | 55 | } | |
| 47 | 56 | ||
| 48 | 57 | function injectAndCodeSign(targetExecutable, resource) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,9 +15,8 @@ skipIfSingleExecutableIsNotSupported(); | |||
| 15 | 15 | const fixtures = require('../common/fixtures'); | |
| 16 | 16 | const tmpdir = require('../common/tmpdir'); | |
| 17 | 17 | const { copyFileSync, writeFileSync, existsSync } = require('fs'); | |
| 18 | - const { execFileSync } = require('child_process'); | ||
| 18 | + const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 19 | 19 | const { join } = require('path'); | |
| 20 | - const { strictEqual } = require('assert'); | ||
| 21 | 20 | const assert = require('assert'); | |
| 22 | 21 | ||
| 23 | 22 | const inputFile = fixtures.path('sea.js'); | |
@@ -44,17 +43,27 @@ writeFileSync(configFile, ` | |||
| 44 | 43 | ||
| 45 | 44 | // Copy input to working directory | |
| 46 | 45 | copyFileSync(inputFile, tmpdir.resolve('sea.js')); | |
| 47 | - execFileSync(process.execPath, ['--experimental-sea-config', 'sea-config.json'], { | ||
| 48 | - cwd: tmpdir.path | ||
| 49 | - }); | ||
| 46 | + spawnSyncAndExitWithoutError( | ||
| 47 | + process.execPath, | ||
| 48 | + ['--experimental-sea-config', 'sea-config.json'], | ||
| 49 | + { cwd: tmpdir.path }, | ||
| 50 | + {}); | ||
| 50 | 51 | ||
| 51 | 52 | assert(existsSync(seaPrepBlob)); | |
| 52 | 53 | ||
| 53 | 54 | copyFileSync(process.execPath, outputFile); | |
| 54 | 55 | injectAndCodeSign(outputFile, seaPrepBlob); | |
| 55 | 56 | ||
| 56 | - const singleExecutableApplicationOutput = execFileSync( | ||
| 57 | + spawnSyncAndExitWithoutError( | ||
| 57 | 58 | outputFile, | |
| 58 | 59 | [ '-a', '--b=c', 'd' ], | |
| 59 | - { env: { COMMON_DIRECTORY: join(__dirname, '..', 'common') } }); | ||
| 60 | - strictEqual(singleExecutableApplicationOutput.toString(), 'Hello, world! 😊\n'); | ||
| 60 | + { | ||
| 61 | + env: { | ||
| 62 | + COMMON_DIRECTORY: join(__dirname, '..', 'common'), | ||
| 63 | + NODE_DEBUG_NATIVE: 'SEA', | ||
| 64 | + ...process.env, | ||
| 65 | + } | ||
| 66 | + }, | ||
| 67 | + { | ||
| 68 | + stdout: 'Hello, world! 😊\n' | ||
| 69 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ skipIfSingleExecutableIsNotSupported(); | |||
| 14 | 14 | ||
| 15 | 15 | const tmpdir = require('../common/tmpdir'); | |
| 16 | 16 | const { copyFileSync, writeFileSync, existsSync } = require('fs'); | |
| 17 | - const { execFileSync } = require('child_process'); | ||
| 17 | + const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 18 | 18 | const assert = require('assert'); | |
| 19 | 19 | ||
| 20 | 20 | const configFile = tmpdir.resolve('sea-config.json'); | |
@@ -31,13 +31,22 @@ writeFileSync(configFile, ` | |||
| 31 | 31 | } | |
| 32 | 32 | `); | |
| 33 | 33 | ||
| 34 | - execFileSync(process.execPath, ['--experimental-sea-config', 'sea-config.json'], { | ||
| 35 | - cwd: tmpdir.path | ||
| 36 | - }); | ||
| 34 | + spawnSyncAndExitWithoutError( | ||
| 35 | + process.execPath, | ||
| 36 | + ['--experimental-sea-config', 'sea-config.json'], | ||
| 37 | + { cwd: tmpdir.path }); | ||
| 37 | 38 | ||
| 38 | 39 | assert(existsSync(seaPrepBlob)); | |
| 39 | 40 | ||
| 40 | 41 | copyFileSync(process.execPath, outputFile); | |
| 41 | 42 | injectAndCodeSign(outputFile, seaPrepBlob); | |
| 42 | 43 | ||
| 43 | - execFileSync(outputFile); | ||
| 44 | + spawnSyncAndExitWithoutError( | ||
| 45 | + outputFile, | ||
| 46 | + { | ||
| 47 | + env: { | ||
| 48 | + NODE_DEBUG_NATIVE: 'SEA', | ||
| 49 | + ...process.env, | ||
| 50 | + } | ||
| 51 | + }, | ||
| 52 | + {}); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,7 +49,11 @@ const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' : | |||
| 49 | 49 | process.execPath, | |
| 50 | 50 | ['--experimental-sea-config', 'sea-config.json'], | |
| 51 | 51 | { | |
| 52 | - cwd: tmpdir.path | ||
| 52 | + cwd: tmpdir.path, | ||
| 53 | + env: { | ||
| 54 | + NODE_DEBUG_NATIVE: 'SEA', | ||
| 55 | + ...process.env, | ||
| 56 | + }, | ||
| 53 | 57 | }, | |
| 54 | 58 | { | |
| 55 | 59 | stderr: /"useCodeCache" is redundant when "useSnapshot" is true/ | |
@@ -61,8 +65,15 @@ const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' : | |||
| 61 | 65 | copyFileSync(process.execPath, outputFile); | |
| 62 | 66 | injectAndCodeSign(outputFile, seaPrepBlob); | |
| 63 | 67 | ||
| 64 | - spawnSyncAndExitWithoutError(outputFile, { | ||
| 65 | - stdout: 'Hello from snapshot', | ||
| 66 | - trim: true, | ||
| 67 | - }); | ||
| 68 | + spawnSyncAndExitWithoutError( | ||
| 69 | + outputFile, | ||
| 70 | + { | ||
| 71 | + env: { | ||
| 72 | + NODE_DEBUG_NATIVE: 'SEA,MKSNAPSHOT', | ||
| 73 | + ...process.env, | ||
| 74 | + } | ||
| 75 | + }, { | ||
| 76 | + stdout: 'Hello from snapshot', | ||
| 77 | + trim: true, | ||
| 78 | + }); | ||
| 68 | 79 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,7 +73,11 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se | |||
| 73 | 73 | process.execPath, | |
| 74 | 74 | ['--experimental-sea-config', 'sea-config.json'], | |
| 75 | 75 | { | |
| 76 | - cwd: tmpdir.path | ||
| 76 | + cwd: tmpdir.path, | ||
| 77 | + env: { | ||
| 78 | + NODE_DEBUG_NATIVE: 'SEA', | ||
| 79 | + ...process.env, | ||
| 80 | + }, | ||
| 77 | 81 | }, | |
| 78 | 82 | { | |
| 79 | 83 | stderr: /Single executable application is an experimental feature/ | |
@@ -86,6 +90,12 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se | |||
| 86 | 90 | ||
| 87 | 91 | spawnSyncAndExitWithoutError( | |
| 88 | 92 | outputFile, | |
| 93 | + { | ||
| 94 | + env: { | ||
| 95 | + NODE_DEBUG_NATIVE: 'SEA,MKSNAPSHOT', | ||
| 96 | + ...process.env, | ||
| 97 | + } | ||
| 98 | + }, | ||
| 89 | 99 | { | |
| 90 | 100 | trim: true, | |
| 91 | 101 | stdout: 'Hello from snapshot', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,9 +15,8 @@ skipIfSingleExecutableIsNotSupported(); | |||
| 15 | 15 | const fixtures = require('../common/fixtures'); | |
| 16 | 16 | const tmpdir = require('../common/tmpdir'); | |
| 17 | 17 | const { copyFileSync, writeFileSync, existsSync } = require('fs'); | |
| 18 | - const { execFileSync } = require('child_process'); | ||
| 18 | + const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 19 | 19 | const { join } = require('path'); | |
| 20 | - const { strictEqual } = require('assert'); | ||
| 21 | 20 | const assert = require('assert'); | |
| 22 | 21 | ||
| 23 | 22 | const inputFile = fixtures.path('sea.js'); | |
@@ -44,17 +43,32 @@ writeFileSync(configFile, ` | |||
| 44 | 43 | ||
| 45 | 44 | // Copy input to working directory | |
| 46 | 45 | copyFileSync(inputFile, tmpdir.resolve('sea.js')); | |
| 47 | - execFileSync(process.execPath, ['--experimental-sea-config', 'sea-config.json'], { | ||
| 48 | - cwd: tmpdir.path | ||
| 49 | - }); | ||
| 46 | + spawnSyncAndExitWithoutError( | ||
| 47 | + process.execPath, | ||
| 48 | + ['--experimental-sea-config', 'sea-config.json'], | ||
| 49 | + { | ||
| 50 | + cwd: tmpdir.path, | ||
| 51 | + env: { | ||
| 52 | + NODE_DEBUG_NATIVE: 'SEA', | ||
| 53 | + ...process.env, | ||
| 54 | + }, | ||
| 55 | + }); | ||
| 50 | 56 | ||
| 51 | 57 | assert(existsSync(seaPrepBlob)); | |
| 52 | 58 | ||
| 53 | 59 | copyFileSync(process.execPath, outputFile); | |
| 54 | 60 | injectAndCodeSign(outputFile, seaPrepBlob); | |
| 55 | 61 | ||
| 56 | - const singleExecutableApplicationOutput = execFileSync( | ||
| 62 | + spawnSyncAndExitWithoutError( | ||
| 57 | 63 | outputFile, | |
| 58 | 64 | [ '-a', '--b=c', 'd' ], | |
| 59 | - { env: { COMMON_DIRECTORY: join(__dirname, '..', 'common') } }); | ||
| 60 | - strictEqual(singleExecutableApplicationOutput.toString(), 'Hello, world! 😊\n'); | ||
| 65 | + { | ||
| 66 | + env: { | ||
| 67 | + COMMON_DIRECTORY: join(__dirname, '..', 'common'), | ||
| 68 | + NODE_DEBUG_NATIVE: 'SEA', | ||
| 69 | + ...process.env, | ||
| 70 | + } | ||
| 71 | + }, | ||
| 72 | + { | ||
| 73 | + stdout: 'Hello, world! 😊\n' | ||
| 74 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,9 +14,8 @@ skipIfSingleExecutableIsNotSupported(); | |||
| 14 | 14 | const fixtures = require('../common/fixtures'); | |
| 15 | 15 | const tmpdir = require('../common/tmpdir'); | |
| 16 | 16 | const { copyFileSync, writeFileSync, existsSync } = require('fs'); | |
| 17 | - const { execFileSync } = require('child_process'); | ||
| 17 | + const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 18 | 18 | const { join } = require('path'); | |
| 19 | - const { strictEqual } = require('assert'); | ||
| 20 | 19 | const assert = require('assert'); | |
| 21 | 20 | ||
| 22 | 21 | const inputFile = fixtures.path('sea.js'); | |
@@ -43,17 +42,27 @@ writeFileSync(configFile, ` | |||
| 43 | 42 | ||
| 44 | 43 | // Copy input to working directory | |
| 45 | 44 | copyFileSync(inputFile, tmpdir.resolve('sea.js')); | |
| 46 | - execFileSync(process.execPath, ['--experimental-sea-config', 'sea-config.json'], { | ||
| 47 | - cwd: tmpdir.path | ||
| 48 | - }); | ||
| 45 | + spawnSyncAndExitWithoutError( | ||
| 46 | + process.execPath, | ||
| 47 | + ['--experimental-sea-config', 'sea-config.json'], | ||
| 48 | + { cwd: tmpdir.path }, | ||
| 49 | + {}); | ||
| 49 | 50 | ||
| 50 | 51 | assert(existsSync(seaPrepBlob)); | |
| 51 | 52 | ||
| 52 | 53 | copyFileSync(process.execPath, outputFile); | |
| 53 | 54 | injectAndCodeSign(outputFile, seaPrepBlob); | |
| 54 | 55 | ||
| 55 | - const singleExecutableApplicationOutput = execFileSync( | ||
| 56 | + spawnSyncAndExitWithoutError( | ||
| 56 | 57 | outputFile, | |
| 57 | 58 | [ '-a', '--b=c', 'd' ], | |
| 58 | - { env: { COMMON_DIRECTORY: join(__dirname, '..', 'common') } }); | ||
| 59 | - strictEqual(singleExecutableApplicationOutput.toString(), 'Hello, world! 😊\n'); | ||
| 59 | + { | ||
| 60 | + env: { | ||
| 61 | + COMMON_DIRECTORY: join(__dirname, '..', 'common'), | ||
| 62 | + NODE_DEBUG_NATIVE: 'SEA', | ||
| 63 | + ...process.env, | ||
| 64 | + } | ||
| 65 | + }, | ||
| 66 | + { | ||
| 67 | + stdout: 'Hello, world! 😊\n' | ||
| 68 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments