Skip to content

Commit 511a3bb

Browse files
committedAug 12, 2024·
chore: add comments about testing choices
·
1 parent b0b1bad commit 511a3bb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎v-next/hardhat/test/internal/builtin-plugins/console/task-action.ts

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ describe("console/task-action", function () {
2727
});
2828

2929
beforeEach(function () {
30+
// Using process.stdin for the input during tests is not reliable as it
31+
// causes the test runner to hang indefinitely. We use a PassThrough stream
32+
// instead. This, in turn, prevents us from using process.stdout for output.
33+
// Hence, we use a PassThrough stream for output as well.
3034
const input = new PassThrough();
3135
const output = new PassThrough();
3236
output.pipe(process.stdout);
@@ -142,13 +146,18 @@ describe("console/task-action", function () {
142146
let history: string;
143147

144148
beforeEach(async function () {
149+
// We use a temporary cache dir to avoid conflicts with other tests
150+
// and global user settings.
145151
cacheDir = await fsPromises.mkdtemp(
146152
path.resolve(os.tmpdir(), "console-action-test-"),
147153
);
148154
history = path.resolve(cacheDir, "console-history.txt");
149155
});
150156

151157
afterEach(async function () {
158+
// We try to remove the temporary cache dir after each test, but we don't
159+
// fail the test if it fails. For example, we have observed that in GHA
160+
// on Windows, the temp dir cannot be removed due to permission issues.
152161
try {
153162
await remove(cacheDir);
154163
} catch (error) {

0 commit comments

Comments
 (0)
Please sign in to comment.