Skip to content

Commit

Permalink
Force evaluation before test execution
Browse files Browse the repository at this point in the history
This makes it so error messages from the build are not wrapped in
error messages for tests.

Before this change the build is performed lazily until the point  when
the tests try to interact with the rootfs under test making it appear
like a build failure is a test error when in reality we didn't even get
to the test.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed Oct 18, 2024
1 parent bbc6e8f commit 0c0e338
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frontend/azlinux/handle_rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func handleRPM(w worker) gwclient.BuildFunc {
return nil, nil, err
}

if err := ref.Evaluate(ctx); err != nil {
return ref, nil, err
}

if imgRef, err := runTests(ctx, client, w, spec, sOpt, st, targetKey, pg); err != nil {
// return the container ref in case of error so it can be used to debug
// the installed package state.
Expand Down
4 changes: 4 additions & 0 deletions frontend/jammy/handle_deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func handleDeb(ctx context.Context, client gwclient.Client) (*gwclient.Result, e
return nil, nil, err
}

if err := ref.Evaluate(ctx); err != nil {
return ref, nil, err
}

if ref, err := runTests(ctx, client, spec, sOpt, st, targetKey, opt); err != nil {
cfg, _ := buildImageConfig(ctx, client, spec, platform, targetKey)
return ref, cfg, err
Expand Down
8 changes: 8 additions & 0 deletions frontend/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func RunTests(ctx context.Context, client gwclient.Client, spec *dalec.Spec, ref
return nil
}

if err := ref.Evaluate(ctx); err != nil {
// Force evaluation here so that any errors for the build itself can surface
// more cleanly.
// Otherwise an error for something wrong in the build (e.g. a failed compilation)
// will look like an error in a test (or all tests).
return err
}

ctr, err := ref.ToState()
if err != nil {
return err
Expand Down

0 comments on commit 0c0e338

Please sign in to comment.