diff options
| author | Paul Buetow <paul@buetow.org> | 2026-07-22 23:51:28 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-07-22 23:51:28 +0300 |
| commit | bc2767c87c4090798c4c7d15e101ed066e947301 (patch) | |
| tree | 0f47a2e0b159a617eb56509bbca1c998196453c4 /integrationtests/fileutils.go | |
| parent | 849951be1d1a7ee9f9302006ccb187bf5b4e36f3 (diff) | |
test: DTail fork — integration test suite and fixtures
Squashed development of the integration test suite (integrationtests/) covering
DCat, DGrep, DMap (serverless + server mode), DTail follow, DServer, DTailHealth,
journal source reads, auth-key fast reconnect, interactive query reload,
client-deadline/timeout behaviour, and the single-mode read/output path.
Includes real test fixtures (dserver*.cfg, dmap_csv_multifile_*.csv.in,
test_server_*.json, *.expected golden files) and deterministic synchronization
helpers (waitContains-style barriers) replacing racy fixed-timing assertions.
Accidental debug/output dumps that earlier commits added here (captured client
output, strace logs, ad-hoc turbo_test_output/manual_output/test_output files,
throwaway debug scripts) are intentionally excluded and gitignored.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'integrationtests/fileutils.go')
| -rw-r--r-- | integrationtests/fileutils.go | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/integrationtests/fileutils.go b/integrationtests/fileutils.go index a1e1051..064a08a 100644 --- a/integrationtests/fileutils.go +++ b/integrationtests/fileutils.go @@ -2,6 +2,7 @@ package integrationtests import ( "bufio" + "context" "crypto/sha256" "encoding/base64" "fmt" @@ -81,7 +82,7 @@ func compareFiles(t *testing.T, fileA, fileB string) error { if bytes, err := exec.Command("diff", "-u", fileA, fileB).Output(); err != nil { sb.Write(bytes) } - return fmt.Errorf(sb.String()) + return fmt.Errorf("%s", sb.String()) } return nil @@ -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) +} |
