Skip to content

Commit

Permalink
release-test: get hhfab path from executable
Browse files Browse the repository at this point in the history
instead of having to pass it as an explicit command line param

Signed-off-by: Emanuele Di Pascale <emanuele@githedgehog.com>
  • Loading branch information
edipascale committed Feb 11, 2025
1 parent 8264577 commit fbc774c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 4 additions & 10 deletions cmd/hhfab/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const (
FlagNameFailFast = "fail-fast"
FlagNameReady = "ready"
FlagNameCollectShowTech = "collect-show-tech"
FlagRegExes = "regexes"
FlagRegEx = "regex"
FlagInvertRegex = "invert-regex"
FlagResultsFile = "results-file"
FlagHhfabBinPath = "hhfab-bin"
Expand Down Expand Up @@ -948,9 +948,9 @@ func Run(ctx context.Context) error {
Usage: "run release tests on current VLAB instance",
Flags: append(defaultFlags,
&cli.StringSliceFlag{
Name: FlagRegExes,
Name: FlagRegEx,
Aliases: []string{"r"},
Usage: "run only tests matched by regular expressions",
Usage: "run only tests matched by regular expression. can be repeated",
},
&cli.BoolFlag{
Name: FlagInvertRegex,
Expand All @@ -960,19 +960,13 @@ func Run(ctx context.Context) error {
Name: FlagResultsFile,
Usage: "path to a file to export test results to in JUnit XML format",
},
&cli.StringFlag{
Name: FlagHhfabBinPath,
Usage: "path to hhfab binary to use for release tests (including the binary itself)",
Value: "hhfab",
},
),
Before: before(false),
Action: func(c *cli.Context) error {
opts := hhfab.ReleaseTestOpts{
Regexes: c.StringSlice(FlagRegExes),
Regexes: c.StringSlice(FlagRegEx),
InvertRegex: c.Bool(FlagInvertRegex),
ResultsFile: c.String(FlagResultsFile),
HhfabBin: c.String(FlagHhfabBinPath),
}
if err := hhfab.DoVLABReleaseTest(ctx, workDir, cacheDir, opts); err != nil {
return fmt.Errorf("release-test: %w", err)
Expand Down
6 changes: 6 additions & 0 deletions pkg/hhfab/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -1586,5 +1586,11 @@ type ReleaseTestOpts struct {
}

func (c *Config) ReleaseTest(ctx context.Context, opts ReleaseTestOpts) error {
self, err := os.Executable()
if err != nil {
return fmt.Errorf("getting executable path: %w", err)
}
opts.HhfabBin = self

return RunReleaseTestSuites(ctx, c.WorkDir, c.CacheDir, opts)
}
2 changes: 1 addition & 1 deletion pkg/hhfab/vlabrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func (c *Config) VLABRun(ctx context.Context, vlab *VLAB, opts VLABRunOpts) erro
return fmt.Errorf("inspecting: %w", err)
}
case OnReadyReleaseTest:
if err := c.ReleaseTest(ctx, ReleaseTestOpts{ResultsFile: "release-test.xml", HhfabBin: "bin/hhfab"}); err != nil {
if err := c.ReleaseTest(ctx, ReleaseTestOpts{ResultsFile: "release-test.xml"}); err != nil {
slog.Warn("Failed to run release test", "err", err)

return fmt.Errorf("release test: %w", err)
Expand Down

0 comments on commit fbc774c

Please sign in to comment.