Skip to content

Commit 6f6bc4a

Browse files
committed
add some comments
1 parent 68b99ca commit 6f6bc4a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/tools/src/snap-test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,24 +152,30 @@ async function runTestCase(name: string, tempTmpDir: string, casesDir: string) {
152152
const cwd = npath.toPortablePath(caseTmpDir);
153153
for (const command of steps.commands) {
154154
debug('running command: %s, cwd: %s, env: %o', command, caseTmpDir, env);
155-
const outpuStreamPath = path.join(caseTmpDir, 'output.log');
156-
const outputStream = await open(outpuStreamPath, 'w');
155+
156+
/// While `@yarnpkg/shell` supports capturing output via in-memory `Writable` streams,
157+
/// it seems not to have stable ordering of stdout/stderr chunks.
158+
/// To ensure stable ordering, we redirect outputs to a file instead.
159+
const outputStreamPath = path.join(caseTmpDir, 'output.log');
160+
const outputStream = await open(outputStreamPath, 'w');
157161

158162
const exitCode = await execute(stripComments(command), [], {
159163
env,
160164
cwd,
161165
stdin: null,
166+
// Declared to be `Writable` but `FileHandle` works too.
162167
stderr: outputStream as any,
163168
stdout: outputStream as any,
164169
glob: {
170+
// Disable glob expansion. Pass args like '--filter=*' as-is.
165171
isGlobPattern: () => false,
166172
match: async () => [],
167173
},
168174
});
169175

170176
outputStream.close();
171177

172-
const output = readFileSync(outpuStreamPath, 'utf-8');
178+
const output = readFileSync(outputStreamPath, 'utf-8');
173179

174180
let commandLine = `> ${command}`;
175181
if (exitCode !== 0) {

0 commit comments

Comments
 (0)