Skip to content

Commit 09d73d5

Browse files
committed
Fix tests on windows
1 parent a2f11ea commit 09d73d5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/partial-compilation/compile-subset-two-indept-files.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22
import assert from "node:assert/strict";
33
import { writeFile } from "node:fs/promises";
44
import path from "node:path";
5-
import { describe, it } from "node:test";
5+
import { beforeEach, describe, it } from "node:test";
66

77
import { useTestProjectTemplate } from "../resolver/helpers.js";
88

99
import { assertFileCounts, getHRE, TestProjectWrapper } from "./helpers.js";
1010

1111
describe("Partial compilation", () => {
1212
describe("Compiling a subset in a project with two independent files", () => {
13+
let oldCwd: string;
14+
15+
beforeEach(() => {
16+
oldCwd = process.cwd();
17+
});
18+
1319
describe("Non-isolated", () => {
1420
it("generates build infos, artifacts and typefiles appropriately", async () => {
1521
await using _project = await useTestProjectTemplate({
@@ -23,6 +29,8 @@ describe("Partial compilation", () => {
2329
const hre = await getHRE(_project);
2430
const project = new TestProjectWrapper(_project, hre);
2531

32+
process.chdir(_project.path);
33+
2634
// Compile first time
2735
await project.compile();
2836
const firstSnapshot = await project.getSnapshot();
@@ -103,6 +111,7 @@ describe("Partial compilation", () => {
103111
// Recompile Bar.sol
104112
await project.compile({ files: ["contracts/Bar.sol"] });
105113
const thirdSnapshot = await project.getSnapshot();
114+
process.chdir(oldCwd);
106115

107116
// Build info 2 will stay because cleanup is only performed on full compilation
108117
assertFileCounts(thirdSnapshot, 3, 2, 2);
@@ -164,6 +173,8 @@ describe("Partial compilation", () => {
164173
const hre = await getHRE(_project);
165174
const project = new TestProjectWrapper(_project, hre);
166175

176+
process.chdir(_project.path);
177+
167178
// Compile first time
168179
await project.compile({ isolated: true });
169180
const firstSnapshot = await project.getSnapshot();
@@ -207,6 +218,8 @@ describe("Partial compilation", () => {
207218

208219
// Compile only Bar.sol
209220
await project.compile({ files: ["contracts/Bar.sol"], isolated: true });
221+
process.chdir(oldCwd);
222+
210223
const secondSnapshot = await project.getSnapshot();
211224

212225
// There will be 3 build infos since cleanup is performed on full compilation

v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/partial-compilation/helpers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { createHardhatRuntimeEnvironment } from "../../../../../../src/internal/
1717
export async function getHRE(
1818
project: TestProject,
1919
): Promise<HardhatRuntimeEnvironment> {
20-
process.chdir(project.path);
2120
return createHardhatRuntimeEnvironment({}, {}, project.path);
2221
}
2322

0 commit comments

Comments
 (0)