Skip to content

Commit 6cf9524

Browse files
committed
fix: cleanup cwd change in deterministic pipeline test
1 parent 6c7fd57 commit 6cf9524

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Diff for: cli/format_test.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,15 @@ go/main.go
568568
func TestDeterministicOrderingInPipeline(t *testing.T) {
569569
as := require.New(t)
570570

571+
// capture current cwd, so we can replace it after the test is finished
572+
cwd, err := os.Getwd()
573+
as.NoError(err)
574+
575+
t.Cleanup(func() {
576+
// return to the previous working directory
577+
as.NoError(os.Chdir(cwd))
578+
})
579+
571580
tempDir := test.TempExamples(t)
572581
configPath := tempDir + "/treefmt.toml"
573582

@@ -595,7 +604,7 @@ func TestDeterministicOrderingInPipeline(t *testing.T) {
595604
},
596605
})
597606

598-
_, err := cmd(t, "-C", tempDir)
607+
_, err = cmd(t, "-C", tempDir)
599608
as.NoError(err)
600609

601610
matcher := regexp.MustCompile("^fmt-(.*)")

0 commit comments

Comments
 (0)