Commit f7a3691
Four test files in filebeat/input/ embedded a GOOS token in the middle of
their name (`*_test_<goos>.go`) instead of ending in `_test.go`. Go only
treats files ending in `_test.go` as test files, and it derives an implicit
build constraint from a trailing `_<goos>` suffix. The combination meant
these files were never considered tests on any platform:
- filestream/{filestream,fswatch,identifier}_test_non_windows.go carried
`//go:build !windows`, while the `_windows` suffix imposed an implicit
`GOOS=windows` constraint. `windows && !windows` is never satisfiable, so
they were dropped on every platform (they showed up in .IgnoredGoFiles).
- file/identifier_test_windows.go (`//go:build windows`) did compile on
Windows, but as ordinary package source rather than a test file, so
`go test` never registered its Test func -- and it linked `testing` into
the production Windows binary of the file input.
As a result, 7 Test functions covering symlink handling, file
rename/remove/truncate detection and inode-marker identity had not run
since ~2020, hiding any regressions from CI. Because they never compiled,
they had also drifted out of sync with the code under test.
Changes:
- Rename to valid, correctly-constrained test files, keeping the build tags:
filestream_test_non_windows.go -> filestream_nonwindows_test.go
identifier_test_non_windows.go -> identifier_nonwindows_test.go
file/identifier_test_windows.go -> identifier_windows_test.go
- Repair the reactivated filestream tests against current APIs
(newFileReader/newFileScanner signatures, FSEvent.Descriptor instead of the
removed FSEvent.Info, modern test helpers, t.TempDir).
- Delete fswatch_test_non_windows.go: its three tests
(TestFileScannerSymlinks, TestFileWatcherRenamedFile,
TestFileWatcherRenamedTruncated) duplicate coverage already provided by the
live TestFileScanner, TestFileWatcher and
TestFileWatcherCopyTruncateWithFingerprint, and depended on the removed
fileWatcher.sameFileFunc injection point.
Net effect: TestLogFileRenamed, TestLogFileRemoved and
TestFileIdentifierInodeMarker now run on non-Windows, TestInodeMarkerError
now runs on Windows, and the file input's production Windows binary no longer
imports testing. fswatch_test_non_windows.go was deletes, other tests already
covered what it was supposed to cover.
Assisted-By: Claude Code
(cherry picked from commit 2a20583)
Co-authored-by: Anderson Queiroz <anderson.queiroz@elastic.co>
1 parent e56aeac commit f7a3691
4 files changed
Lines changed: 31 additions & 256 deletions
File tree
- filebeat/input
- filestream
- file
File renamed without changes.
Lines changed: 21 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | | - | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | | - | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | | - | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
78 | | - | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
96 | | - | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| |||
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
This file was deleted.
Lines changed: 10 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | | - | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | | - | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
69 | | - | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | | - | |
| 77 | + | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
0 commit comments