test: throw if no valid outDir (#22412)
This commit is contained in:
parent
36f982aee2
commit
02cf5baa32
2 changed files with 12 additions and 1 deletions
|
@ -32,6 +32,12 @@ by coding style rules. `npm run lint-py` will check all Python, using
|
||||||
|
|
||||||
## Unit Tests
|
## Unit Tests
|
||||||
|
|
||||||
|
If you are not using [build-tools](https://github.com/electron/build-tools),
|
||||||
|
ensure that that name you have configured for your
|
||||||
|
local build of Electron is one of `Testing`, `Release`, `Default`, `Debug`, or
|
||||||
|
you have set `process.env.ELECTRON_OUT_DIR`. Without these set, Electron will fail
|
||||||
|
to perform some pre-testing steps.
|
||||||
|
|
||||||
To run all unit tests, run `npm run test`. The unit tests are an Electron
|
To run all unit tests, run `npm run test`. The unit tests are an Electron
|
||||||
app (surprise!) that can be found in the `spec` folder. Note that it has
|
app (surprise!) that can be found in the `spec` folder. Note that it has
|
||||||
its own `package.json` and that its dependencies are therefore not defined
|
its own `package.json` and that its dependencies are therefore not defined
|
||||||
|
|
|
@ -27,6 +27,7 @@ function getElectronExec () {
|
||||||
|
|
||||||
function getOutDir (options = {}) {
|
function getOutDir (options = {}) {
|
||||||
const shouldLog = options.shouldLog || false
|
const shouldLog = options.shouldLog || false
|
||||||
|
const presetDirs = ['Testing', 'Release', 'Default', 'Debug']
|
||||||
|
|
||||||
if (options.outDir || process.env.ELECTRON_OUT_DIR) {
|
if (options.outDir || process.env.ELECTRON_OUT_DIR) {
|
||||||
const outDir = options.outDir || process.env.ELECTRON_OUT_DIR
|
const outDir = options.outDir || process.env.ELECTRON_OUT_DIR
|
||||||
|
@ -41,7 +42,7 @@ function getOutDir (options = {}) {
|
||||||
// Throw error if user passed/set nonexistent directory.
|
// Throw error if user passed/set nonexistent directory.
|
||||||
throw new Error(`${outDir} directory not configured on your machine.`)
|
throw new Error(`${outDir} directory not configured on your machine.`)
|
||||||
} else {
|
} else {
|
||||||
for (const buildType of ['Testing', 'Release', 'Default', 'Debug']) {
|
for (const buildType of presetDirs) {
|
||||||
const outPath = path.resolve(SRC_DIR, 'out', buildType)
|
const outPath = path.resolve(SRC_DIR, 'out', buildType)
|
||||||
if (fs.existsSync(outPath)) {
|
if (fs.existsSync(outPath)) {
|
||||||
if (shouldLog) console.log(`OUT_DIR is: ${buildType}`)
|
if (shouldLog) console.log(`OUT_DIR is: ${buildType}`)
|
||||||
|
@ -49,6 +50,10 @@ function getOutDir (options = {}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we got here, it means process.env.ELECTRON_OUT_DIR was not
|
||||||
|
// set and none of the preset options could be found in /out, so throw
|
||||||
|
throw new Error(`No valid out directory found; use one of ${presetDirs.join(',')} or set process.env.ELECTRON_OUT_DIR`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAbsoluteElectronExec () {
|
function getAbsoluteElectronExec () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue