2
2
import assert from "node:assert/strict" ;
3
3
import { writeFile } from "node:fs/promises" ;
4
4
import path from "node:path" ;
5
- import { describe , it } from "node:test" ;
5
+ import { beforeEach , describe , it } from "node:test" ;
6
6
7
7
import { useTestProjectTemplate } from "../resolver/helpers.js" ;
8
8
9
9
import { assertFileCounts , getHRE , TestProjectWrapper } from "./helpers.js" ;
10
10
11
11
describe ( "Partial compilation" , ( ) => {
12
12
describe ( "Compiling a subset in a project with two independent files" , ( ) => {
13
+ let oldCwd : string ;
14
+
15
+ beforeEach ( ( ) => {
16
+ oldCwd = process . cwd ( ) ;
17
+ } ) ;
18
+
13
19
describe ( "Non-isolated" , ( ) => {
14
20
it ( "generates build infos, artifacts and typefiles appropriately" , async ( ) => {
15
21
await using _project = await useTestProjectTemplate ( {
@@ -23,6 +29,8 @@ describe("Partial compilation", () => {
23
29
const hre = await getHRE ( _project ) ;
24
30
const project = new TestProjectWrapper ( _project , hre ) ;
25
31
32
+ process . chdir ( _project . path ) ;
33
+
26
34
// Compile first time
27
35
await project . compile ( ) ;
28
36
const firstSnapshot = await project . getSnapshot ( ) ;
@@ -103,6 +111,7 @@ describe("Partial compilation", () => {
103
111
// Recompile Bar.sol
104
112
await project . compile ( { files : [ "contracts/Bar.sol" ] } ) ;
105
113
const thirdSnapshot = await project . getSnapshot ( ) ;
114
+ process . chdir ( oldCwd ) ;
106
115
107
116
// Build info 2 will stay because cleanup is only performed on full compilation
108
117
assertFileCounts ( thirdSnapshot , 3 , 2 , 2 ) ;
@@ -164,6 +173,8 @@ describe("Partial compilation", () => {
164
173
const hre = await getHRE ( _project ) ;
165
174
const project = new TestProjectWrapper ( _project , hre ) ;
166
175
176
+ process . chdir ( _project . path ) ;
177
+
167
178
// Compile first time
168
179
await project . compile ( { isolated : true } ) ;
169
180
const firstSnapshot = await project . getSnapshot ( ) ;
@@ -207,6 +218,8 @@ describe("Partial compilation", () => {
207
218
208
219
// Compile only Bar.sol
209
220
await project . compile ( { files : [ "contracts/Bar.sol" ] , isolated : true } ) ;
221
+ process . chdir ( oldCwd ) ;
222
+
210
223
const secondSnapshot = await project . getSnapshot ( ) ;
211
224
212
225
// There will be 3 build infos since cleanup is performed on full compilation
0 commit comments