Skip to content

fix(skill): tail_file test uses OS-specific absolute path - #231

Merged
singchia merged 1 commit into
ongridio:mainfrom
anrenlx2025:fix/tail-file-test-cross-platform
Aug 11, 2026
Merged

singchia merged 1 commit into
ongridio:mainfrom
anrenlx2025:fix/tail-file-test-cross-platform

Conversation

@anrenlx2025

@anrenlx2025 anrenlx2025 commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Cross-platform fix for TestTailFile_Execute_NotFound. Independent of the Windows edge PR chain (#228 / #229 / #230).

Problem

The test hardcoded /tmp/this-file-does-not-exist-ongrid-test as a non-existent absolute path. On Windows /tmp/... is not absolute (Windows requires a C:\-style drive prefix), so filepath.IsAbs returns false, the test gets "path must be absolute" instead of the expected file-not-found error, FAIL on Windows.

Fix

Use filepath.Join(os.TempDir(), "..."):

  • Linux/macOS: /tmp/this-file-does-not-exist-ongrid-test
  • Windows: C:\Users\<user>\AppData\Local\Temp\this-file-does-not-exist-ongrid-test

Both satisfy filepath.IsAbs, preserving the original test intent.

Scope

1 file, 3 insertions / 1 deletion. Test-only change, no production code touched.

Verification

  • go test -run TestTailFile_Execute_NotFound ./internal/skill/builtin/ passes on Windows
  • Full go test ./internal/skill/builtin/ passes

Why independent PR

Discovered while running PR3 Windows tests, but the bug and fix are platform-wide (not Windows-edge specific). Keeping it independent lets it merge quickly without waiting for the Windows edge chain (which will take 1-2 months to review).

Contribution

@singchia

singchia commented Aug 7, 2026

Copy link
Copy Markdown
Member

Thanks for the focused test portability fix. The change itself looks reasonable, but this PR is currently BLOCKED and has no CI results. Please rebase it onto the latest main and restore the required checks; once the test suite is green, this can be reviewed and merged independently of the Windows Edge stack.

upstream tail_file_test.go 第 114 行用 hardcoded "/tmp/..." 作为不存在的绝对路径,
在 Windows 上 /tmp/... 不是 absolute(Windows 需要 C:\ 前缀),filepath.IsAbs
返回 false → 测试期望 err==nil 但实际返回 "path must be absolute" → FAIL。

改用 filepath.Join(os.TempDir(), "...") 拼路径:
- Linux/macOS: /tmp/this-file-does-not-exist-ongrid-test
- Windows:     C:\Users\<user>\AppData\Local\Temp\this-file-does-not-exist-ongrid-test

两平台都满足 filepath.IsAbs,测试达到原意图(验证 file-not-found 错误)。

独立于 Windows edge PR 链(PR1 ongridio#228 / PR2 ongridio#229 / cleanup ongridio#230 / PR3 待开),
对所有平台有益,可立即 merge 到 main。
@anrenlx2025
anrenlx2025 force-pushed the fix/tail-file-test-cross-platform branch from 4344263 to 1daeb93 Compare August 7, 2026 09:19
@anrenlx2025

Copy link
Copy Markdown
Contributor Author

@singchia Rebased onto ongridio/ongrid@efc0ddb (was 106 behind). Diff unchanged: 1 file, +3/-1 (internal/skill/builtin/tail_file_test.go).

Local verification:

  • ✅ go test ./internal/skill/builtin/ — Windows native PASS (5 tests)
  • ✅ GOOS=linux go build ./internal/skill/builtin/ — exit 0
  • ✅ GOOS=linux go vet ./internal/skill/builtin/ — exit 0
  • ✅ GOOS=linux go test -c — exit 0

CI status: Workflow runs are in action_required state (fork PR default). Could you approve the CI run for this PR? Once approved, the test-only
3-line change should pass quickly. This PR is independent of the Windows edge stack (#228/#229/#230) per your earlier guidance.

@singchia

Copy link
Copy Markdown
Member

The cross-platform direction is right. Please use a test-owned directory instead of a fixed filename under os.TempDir():

notExistPath := filepath.Join(t.TempDir(), "missing.log")

os.TempDir()/this-file-does-not-exist-ongrid-test can already exist because of another test run or a user-created file, which makes this specific not-found assertion flaky. t.TempDir() keeps the Windows absolute-path fix and guarantees the target has not been created.

@singchia
singchia merged commit ff893ef into ongridio:main Aug 11, 2026
4 of 5 checks passed
@anrenlx2025
anrenlx2025 deleted the fix/tail-file-test-cross-platform branch August 11, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants