aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/internal/cgrouptest/cgrouptest_linux.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/internal/cgrouptest/cgrouptest_linux.go b/src/internal/cgrouptest/cgrouptest_linux.go
index ad9599c938..72380debc6 100644
--- a/src/internal/cgrouptest/cgrouptest_linux.go
+++ b/src/internal/cgrouptest/cgrouptest_linux.go
@@ -74,16 +74,16 @@ func InCgroupV2(t *testing.T, fn func(*CgroupV2)) {
//
// TODO(prattmic): Consider running everything in a subprocess just so
// we can clean up if it throws or otherwise doesn't run the defers.
- defer func() {
+ t.Cleanup(func() {
if err := os.Remove(path); err != nil {
// Not much we can do, but at least inform of the
// problem.
t.Errorf("Error removing cgroup directory: %v", err)
}
- }()
+ })
migrateTo(t, path)
- defer migrateTo(t, orig)
+ t.Cleanup(func() { migrateTo(t, orig) })
c := &CgroupV2{
orig: orig,