Skip to content

Commit

Permalink
Merge pull request #126 from crazy-max/test-fix-timer
Browse files Browse the repository at this point in the history
test: fix timer reset
  • Loading branch information
crazy-max committed Sep 20, 2024
2 parents d0f0129 + f4794c8 commit ea9f9fb
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 7 deletions.
6 changes: 0 additions & 6 deletions test/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ RUN cp /etc/foo /etc/bar
fstest.CreateFile("Dockerfile", dockerfile, 0600),
fstest.CreateFile("foo", []byte("foo"), 0600),
)
b.ResetTimer()
b.StartTimer()
out, err := buildxBuildCmd(sb, withArgs(dir))
b.StopTimer()
Expand All @@ -65,7 +64,6 @@ COPY --from=base /etc/bar /bar
fstest.CreateFile("Dockerfile", dockerfile, 0600),
fstest.CreateFile("foo", []byte("foo"), 0600),
)
b.ResetTimer()
b.StartTimer()
out, err := buildxBuildCmd(sb, withArgs(dir))
b.StopTimer()
Expand All @@ -84,7 +82,6 @@ RUN --mount=type=secret,id=SECRET cat /run/secrets/SECRET
fstest.CreateFile("Dockerfile", dockerfile, 0600),
fstest.CreateFile("secret.txt", []byte("mysecret"), 0600),
)
b.ResetTimer()
b.StartTimer()
out, err := buildxBuildCmd(sb, withDir(dir), withArgs("--secret=id=SECRET,src=secret.txt", "."))
b.StopTimer()
Expand All @@ -93,7 +90,6 @@ RUN --mount=type=secret,id=SECRET cat /run/secrets/SECRET
}

func benchmarkBuildRemote(b *testing.B, sb testutil.Sandbox) {
b.ResetTimer()
b.StartTimer()
out, err := buildxBuildCmd(sb, withArgs(
"--build-arg=BUILDKIT_SYNTAX="+dockerfileImagePin,
Expand Down Expand Up @@ -139,7 +135,6 @@ RUN cp /etc/foo /etc/bar
require.NoError(b, err, out)
}()
}
b.ResetTimer()
b.StartTimer()
wg.Wait()
b.StopTimer()
Expand Down Expand Up @@ -174,7 +169,6 @@ RUN du -sh . && tree .
fstest.Apply(appliers...),
)

b.ResetTimer()
b.StartTimer()
out, err := buildxBuildCmd(sb, withArgs(dir))
b.StopTimer()
Expand Down
1 change: 0 additions & 1 deletion test/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func testDaemonDebugHeap(t *testing.T, sb testutil.Sandbox) {

func benchmarkDaemonVersion(b *testing.B, sb testutil.Sandbox) {
buildkitdPath := path.Join(sb.BinsDir(), sb.Name(), "buildkitd")
b.ResetTimer()
b.StartTimer()
err := exec.Command(buildkitdPath, "--version").Run()
b.StopTimer()
Expand Down
1 change: 1 addition & 0 deletions util/testutil/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func Run(tb testing.TB, runners []Runner, opt ...TestOpt) {
runner.Run(tb, sb)
}
if b, ok := tb.(*testing.B); ok {
b.ResetTimer()
for i := 0; i < b.N; i++ {
runWithSandbox(b)
}
Expand Down

0 comments on commit ea9f9fb

Please sign in to comment.