diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-25 22:08:34 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-25 22:08:34 +0300 |
| commit | 146ec97a51c1ab7ca96795310de80a0045db2699 (patch) | |
| tree | 67675b8f4975844744dc24bbcaaebc1c4c1caa9b /integrationtests/fileutils.go | |
| parent | 07a1147a7291938d2433efda5ecb2855cd1e3f18 (diff) | |
Add comprehensive test logging infrastructure to integration tests
- Add test logging infrastructure to track command execution and file comparisons
- Generate .log files for each test with command history and manual verification commands
- Ensure all temporary test files use .tmp suffix for consistency
- Clean up .tmp files before each test run (not after) for clean test starts
- Update .gitignore to exclude generated test artifacts (.log, .query files)
- Fix dserver test configurations to use .tmp suffix for output files
- Fix expected test outputs for dgrep context tests
This change improves test debugging and verification by providing detailed logs
of what each test does and allows manual verification of test results.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'integrationtests/fileutils.go')
| -rw-r--r-- | integrationtests/fileutils.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/integrationtests/fileutils.go b/integrationtests/fileutils.go index ffc26fe..064a08a 100644 --- a/integrationtests/fileutils.go +++ b/integrationtests/fileutils.go @@ -2,6 +2,7 @@ package integrationtests import ( "bufio" + "context" "crypto/sha256" "encoding/base64" "fmt" @@ -115,3 +116,27 @@ func shaOfFile(t *testing.T, file string) string { t.Log("SHA", file, sha) return sha } + +// compareFilesWithContext is a context-aware version of compareFiles that logs comparisons +func compareFilesWithContext(ctx context.Context, t *testing.T, fileA, fileB string) error { + if logger := GetTestLogger(ctx); logger != nil { + logger.LogFileComparison(fileA, fileB, "exact (SHA256)") + } + return compareFiles(t, fileA, fileB) +} + +// compareFilesContentsWithContext is a context-aware version of compareFilesContents that logs comparisons +func compareFilesContentsWithContext(ctx context.Context, t *testing.T, fileA, fileB string) error { + if logger := GetTestLogger(ctx); logger != nil { + logger.LogFileComparison(fileA, fileB, "contents (order-independent)") + } + return compareFilesContents(t, fileA, fileB) +} + +// fileContainsStrWithContext is a context-aware version of fileContainsStr that logs comparisons +func fileContainsStrWithContext(ctx context.Context, t *testing.T, file, str string) error { + if logger := GetTestLogger(ctx); logger != nil { + logger.LogFileComparison(file, fmt.Sprintf("string '%s'", str), "contains check") + } + return fileContainsStr(t, file, str) +} |
