Skip to content

Commit f64fddf

Browse files
authored
chore(test-utils): improve handling of running docker containers (open-telemetry#1695)
- Convert the output of run commands to a string that is readable. - No need to `docker rm ...` test containers for `npm run test:local` usage because the `docker run --rm ...` option will remove them when stopped.
1 parent 5675c49 commit f64fddf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/opentelemetry-test-utils/src/test-utils.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,23 @@ export function startDocker(db: keyof typeof dockerRunCmds) {
6060

6161
export function cleanUpDocker(db: keyof typeof dockerRunCmds) {
6262
run(`docker stop otel-${db}`);
63-
run(`docker rm otel-${db}`);
6463
}
6564

6665
function run(cmd: string) {
6766
try {
6867
const proc = childProcess.spawnSync(cmd, {
6968
shell: true,
7069
});
70+
const output = Buffer.concat(
71+
proc.output.filter(c => c) as Buffer[]
72+
).toString('utf8');
7173
if (proc.status !== 0) {
7274
console.error('Failed run command:', cmd);
73-
console.error(proc.output);
75+
console.error(output);
7476
}
7577
return {
7678
code: proc.status,
77-
output: proc.output
78-
.map(v => String.fromCharCode.apply(null, v as any))
79-
.join(''),
79+
output,
8080
};
8181
} catch (e) {
8282
console.log(e);

0 commit comments

Comments
 (0)