summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli/src/integrationtests/harness.ts
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-02-01 13:13:43 +0100
committerMS <ms@taler.net>2021-02-01 13:13:43 +0100
commitc3ca3aa7fcf7065669ed2069cd5acad9e472e2ae (patch)
treea455bd478ae8dd492477551f42728926fab60491 /packages/taler-wallet-cli/src/integrationtests/harness.ts
parentca2943b270aa47d794cce055dd5f1f90ec88729f (diff)
downloadwallet-core-c3ca3aa7fcf7065669ed2069cd5acad9e472e2ae.tar.gz
wallet-core-c3ca3aa7fcf7065669ed2069cd5acad9e472e2ae.tar.bz2
wallet-core-c3ca3aa7fcf7065669ed2069cd5acad9e472e2ae.zip
Allow passing a env when running processes.
This brings the libeufin-basic test to pass.
Diffstat (limited to 'packages/taler-wallet-cli/src/integrationtests/harness.ts')
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/harness.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/taler-wallet-cli/src/integrationtests/harness.ts b/packages/taler-wallet-cli/src/integrationtests/harness.ts
index eb14b32b9..3a56f4cda 100644
--- a/packages/taler-wallet-cli/src/integrationtests/harness.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/harness.ts
@@ -113,6 +113,21 @@ interface WaitResult {
}
/**
+ * Returns a new object being the current environment
+ * plus the values given in the parameter.
+ */
+export function extendEnv(extension: {[index: string]: string}): {[index: string]: string | undefined} {
+ let ret: {[index: string]: string | undefined} = {};
+ for (let v in process.env) {
+ ret[v] = process.env[v];
+ }
+ for (let v in extension) {
+ ret[v] = extension[v];
+ }
+ return ret;
+}
+
+/**
* Run a shell command, return stdout.
*/
export async function sh(
@@ -175,6 +190,7 @@ export async function runCommand(
logName: string,
command: string,
args: string[],
+ env: {[index: string]: string | undefined} = process.env
): Promise<string> {
console.log("runing command", shellescape([command, ...args]));
return new Promise((resolve, reject) => {
@@ -182,6 +198,7 @@ export async function runCommand(
const proc = spawn(command, args, {
stdio: ["inherit", "pipe", "pipe"],
shell: false,
+ env: env
});
proc.stdout.on("data", (x) => {
if (x instanceof Buffer) {
@@ -323,12 +340,14 @@ export class GlobalTestState {
command: string,
args: string[],
logName: string,
+ env: {[index: string] : string | undefined} = process.env
): ProcessWrapper {
console.log(
`spawning process (${logName}): ${shellescape([command, ...args])}`,
);
const proc = spawn(command, args, {
stdio: ["inherit", "pipe", "pipe"],
+ env: env
});
console.log(`spawned process (${logName}) with pid ${proc.pid}`);
proc.on("error", (err) => {