Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cmd/waza/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,26 @@ func runCommandE(cmd *cobra.Command, args []string) error {

if len(specPaths) == 1 {
results, err := runCommandForSpec(cmd, specPaths[0])

// Only write outputs when the run produced meaningful results:
// either success (err == nil) or test failures (outcomes are still valid).
// For other errors (spec load/parse failures), skip writing and return early.
if err != nil {
if _, ok := errors.AsType[*TestFailureError](err); !ok {
return err
}
}

// Write structured directory output when --output-dir is specified
if outputDir != "" {
Comment thread
chlowell marked this conversation as resolved.
if wErr := writeOutputDir(outputDir, []skillRunResult{
{skillName: specPaths[0].skillName, outcomes: results},
}); wErr != nil {
return fmt.Errorf("failed to write output directory: %w", wErr)
}
Comment thread
chlowell marked this conversation as resolved.
}

// Auto-upload after all local writes succeed
autoUploadOutcomes(cmd, cfg, results)
return err
}
Expand Down
33 changes: 33 additions & 0 deletions cmd/waza/cmd_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1905,6 +1905,39 @@ func TestRunCommand_OutputDirMutualExclusion(t *testing.T) {
assert.Contains(t, err.Error(), "--output and --output-dir are mutually exclusive")
}

func TestRunCommand_OutputDirSingleSkill(t *testing.T) {
resetRunGlobals()
defer resetRunGlobals()

specPath := createTestSpec(t, "mock")
outDir := filepath.Join(t.TempDir(), "results")

cmd := newRunCommand()
cmd.SetArgs([]string{specPath, "--output-dir", outDir})

err := cmd.Execute()
require.NoError(t, err)

// Verify output directory was created with a result JSON file
entries, err := os.ReadDir(outDir)
require.NoError(t, err)
require.NotEmpty(t, entries, "expected output files in --output-dir")

// Find and validate the JSON result file
var found bool
for _, e := range entries {
if filepath.Ext(e.Name()) == ".json" {
data, err := os.ReadFile(filepath.Join(outDir, e.Name()))
require.NoError(t, err)
var outcome models.EvaluationOutcome
require.NoError(t, json.Unmarshal(data, &outcome))
assert.Equal(t, "test-eval", outcome.BenchName)
found = true
}
}
assert.True(t, found, "expected at least one .json result in output dir")
}

func TestWriteOutputDir_SingleSkill(t *testing.T) {
dir := t.TempDir()

Expand Down
Loading