-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1251 from zowe/next-daemon-enable
Next daemon enable for new pipeline
- Loading branch information
Showing
42 changed files
with
9,557 additions
and
8,965 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const child_process: any = jest.genMockFromModule("child_process"); | ||
|
||
const useRealFunction: string = "useRealFunction"; | ||
let execSyncOutput: string = useRealFunction; | ||
const spawnSyncOutput = { | ||
"stdout": useRealFunction | ||
}; | ||
|
||
// tests can set their own output value for execSync | ||
function setExecSyncOutput(outputVal: string) { | ||
execSyncOutput = outputVal; | ||
} | ||
|
||
// tests can set their own output value for spawnSync | ||
function setSpawnSyncOutput(outputVal: string) { | ||
spawnSyncOutput.stdout = outputVal; | ||
} | ||
// Mock function to use for child_process.execSync | ||
function execSyncMock(cmd: string, options: Object) { | ||
if (execSyncOutput === useRealFunction) { | ||
// run the real execSync | ||
const execSyncReal = require.requireActual("child_process").execSync; | ||
return execSyncReal(cmd, options); | ||
} else { | ||
// return the output that the test set with setExecSyncOutput(). | ||
return execSyncOutput; | ||
} | ||
} | ||
|
||
// Mock function to use for child_process.spawnSync | ||
function spawnSyncMock(cmd: string, args: [string], options: Object) { | ||
if (spawnSyncOutput.stdout === useRealFunction) { | ||
// run the real spawnSync | ||
const spawnSyncReal = require.requireActual("child_process").spawnSync; | ||
return spawnSyncReal(cmd, args, options); | ||
} else { | ||
// return the output that the test set with setSpawnSyncOutput(). | ||
return spawnSyncOutput; | ||
} | ||
} | ||
|
||
child_process.setExecSyncOutput = setExecSyncOutput; | ||
child_process.execSync = execSyncMock; | ||
|
||
child_process.setSpawnSyncOutput = setSpawnSyncOutput; | ||
child_process.spawnSync = spawnSyncMock; | ||
|
||
module.exports = child_process; |
Oops, something went wrong.