TestResolveIncludePath_AllPathStyles exercises every path style that ResolveIncludePath must handle: - Explicit current-dir-relative ("./file.md") - Standard relative ("file.md", "subdir/file.md") - .github/-prefixed repo-root (".github/agents/planner.md") - /.github/-prefixed repo
(t *testing.T)
| 346 | // - baseDir without .github parent (plain relative fallback) |
| 347 | // - Windows-style backslash paths (normalized via filepath.ToSlash on Windows) |
| 348 | func TestResolveIncludePath_AllPathStyles(t *testing.T) { |
| 349 | tempDir, err := os.MkdirTemp("", "test_all_path_styles") |
| 350 | require.NoError(t, err, "should create temp dir") |
| 351 | defer os.RemoveAll(tempDir) |
| 352 | |
| 353 | // Build a full repo layout: |
| 354 | // <tempDir>/repo/ |
| 355 | // .github/ |
| 356 | // workflows/ |
| 357 | // workflow.md |
| 358 | // sub/ |
| 359 | // nested.md |
| 360 | // agents/ |
| 361 | // planner.md |
| 362 | // sub/ |
| 363 | // nested.md |
| 364 | // .agents/ |
| 365 | // agent.md |
| 366 | // sub/ |
| 367 | // nested.md |
| 368 | repoRoot := filepath.Join(tempDir, "repo") |
| 369 | workflowsDir := filepath.Join(repoRoot, ".github", "workflows") |
| 370 | workflowsSubDir := filepath.Join(workflowsDir, "sub") |
| 371 | agentsDir := filepath.Join(repoRoot, ".github", "agents") |
| 372 | agentsSubDir := filepath.Join(agentsDir, "sub") |
| 373 | dotAgentsDir := filepath.Join(repoRoot, ".agents") |
| 374 | dotAgentsSubDir := filepath.Join(dotAgentsDir, "sub") |
| 375 | |
| 376 | for _, dir := range []string{workflowsSubDir, agentsSubDir, dotAgentsSubDir} { |
| 377 | require.NoError(t, os.MkdirAll(dir, 0755), "should create dir %s", dir) |
| 378 | } |
| 379 | |
| 380 | workflowFile := filepath.Join(workflowsDir, "workflow.md") |
| 381 | workflowNestedFile := filepath.Join(workflowsSubDir, "nested.md") |
| 382 | agentFile := filepath.Join(agentsDir, "planner.md") |
| 383 | agentNestedFile := filepath.Join(agentsSubDir, "nested.md") |
| 384 | dotAgentFile := filepath.Join(dotAgentsDir, "agent.md") |
| 385 | dotAgentNestedFile := filepath.Join(dotAgentsSubDir, "nested.md") |
| 386 | |
| 387 | for _, f := range []string{workflowFile, workflowNestedFile, agentFile, agentNestedFile, dotAgentFile, dotAgentNestedFile} { |
| 388 | require.NoError(t, os.WriteFile(f, []byte("test"), 0644), "should write %s", f) |
| 389 | } |
| 390 | |
| 391 | // A directory outside any .github tree for the "no ancestor" tests. |
| 392 | noGithubDir := filepath.Join(tempDir, "standalone") |
| 393 | require.NoError(t, os.MkdirAll(noGithubDir, 0755), "should create standalone dir") |
| 394 | standaloneFile := filepath.Join(noGithubDir, "helper.md") |
| 395 | require.NoError(t, os.WriteFile(standaloneFile, []byte("test"), 0644), "should write standalone file") |
| 396 | |
| 397 | tests := []struct { |
| 398 | name string |
| 399 | filePath string |
| 400 | baseDir string |
| 401 | expected string |
| 402 | wantErr bool |
| 403 | }{ |
| 404 | // ── Standard relative paths ───────────────────────────────────────────── |
| 405 | { |
nothing calls this directly
no test coverage detected