Skip to content

Commit e5f5a7b

Browse files
data-douserCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Nathan Randall <70299490+data-douser@users.noreply.github.com>
1 parent 13855d4 commit e5f5a7b

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

client/internal/testing/runner.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type Runner struct {
5555

5656
// NewRunner creates a new integration test runner.
5757
func NewRunner(caller ToolCaller, opts RunnerOptions) *Runner {
58-
tmpBase := filepath.Join(opts.RepoRoot, "server", ".tmp")
58+
tmpBase := filepath.Join(opts.RepoRoot, ".tmp")
5959
return &Runner{
6060
caller: caller,
6161
options: opts,
@@ -198,8 +198,9 @@ func (r *Runner) runSingleTest(toolName, testCase, toolDir string) {
198198
// monitoring-state.json parameters, and tool-specific defaults — in that order.
199199
params, err := buildToolParams(r.options.RepoRoot, toolName, testCase, testDir)
200200
if err != nil {
201-
r.recordResult(toolName, testCase, false, fmt.Sprintf("skipped: %v", err), 0)
202-
fmt.Printf(" skip %s (%v)\n", testCase, err)
201+
elapsed := time.Since(start)
202+
r.recordResult(toolName, testCase, false, fmt.Sprintf("parameter resolution error: %v", err), elapsed)
203+
fmt.Printf(" FAIL %s (parameter resolution error: %v) [%.1fs]\n", testCase, err, elapsed.Seconds())
203204
return
204205
}
205206

@@ -295,15 +296,34 @@ func resolvePathPlaceholders(params map[string]any, tmpBase string) map[string]a
295296
}
296297
result := make(map[string]any, len(params))
297298
for k, v := range params {
298-
if s, ok := v.(string); ok && strings.Contains(s, "{{tmpdir}}") {
299-
result[k] = strings.ReplaceAll(s, "{{tmpdir}}", tmpBase)
300-
} else {
301-
result[k] = v
302-
}
299+
result[k] = resolvePathPlaceholderValue(v, tmpBase)
303300
}
304301
return result
305302
}
306303

304+
func resolvePathPlaceholderValue(value any, tmpBase string) any {
305+
switch v := value.(type) {
306+
case string:
307+
if strings.Contains(v, "{{tmpdir}}") {
308+
return strings.ReplaceAll(v, "{{tmpdir}}", tmpBase)
309+
}
310+
return v
311+
case map[string]any:
312+
result := make(map[string]any, len(v))
313+
for key, nestedValue := range v {
314+
result[key] = resolvePathPlaceholderValue(nestedValue, tmpBase)
315+
}
316+
return result
317+
case []any:
318+
result := make([]any, len(v))
319+
for i, nestedValue := range v {
320+
result[i] = resolvePathPlaceholderValue(nestedValue, tmpBase)
321+
}
322+
return result
323+
default:
324+
return value
325+
}
326+
}
307327
func toolPriority(name string) int {
308328
switch name {
309329
case "codeql_pack_install":

0 commit comments

Comments
 (0)