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/dserver_test.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/dserver_test.go')
| -rw-r--r-- | integrationtests/dserver_test.go | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/integrationtests/dserver_test.go b/integrationtests/dserver_test.go index eaca23b..663098d 100644 --- a/integrationtests/dserver_test.go +++ b/integrationtests/dserver_test.go @@ -17,18 +17,18 @@ func TestDServer1(t *testing.T) { return } // Testing a scheduled query. + cleanupTmpFiles(t) + testLogger := NewTestLogger("TestDServer1") + defer testLogger.WriteLogFile() - csvFile := "dserver1.csv" + csvFile := "dserver1.csv.tmp" expectedCsvFile := "dserver1.csv.expected" queryFile := fmt.Sprintf("%s.query", csvFile) expectedQueryFile := "dserver1.csv.query.expected" - // In case files still exists from previous test run. - os.Remove(csvFile) - os.Remove(queryFile) - - ctx, cancel := context.WithCancel(context.Background()) + baseCtx, cancel := context.WithCancel(context.Background()) defer cancel() + ctx := WithTestLogger(baseCtx, testLogger) stdoutCh, stderrCh, cmdErrCh, err := startCommand(ctx, t, "", "../dserver", @@ -46,17 +46,14 @@ func TestDServer1(t *testing.T) { waitForCommand(ctx, t, stdoutCh, stderrCh, cmdErrCh) - if err := compareFiles(t, csvFile, expectedCsvFile); err != nil { + if err := compareFilesWithContext(ctx, t, csvFile, expectedCsvFile); err != nil { t.Error(err) return } - if err := compareFiles(t, queryFile, expectedQueryFile); err != nil { + if err := compareFilesWithContext(ctx, t, queryFile, expectedQueryFile); err != nil { t.Error(err) return } - - os.Remove(csvFile) - os.Remove(queryFile) } func TestDServer2(t *testing.T) { @@ -66,15 +63,19 @@ func TestDServer2(t *testing.T) { } // Testing a continious query. + cleanupTmpFiles(t) + testLogger := NewTestLogger("TestDServer2") + defer testLogger.WriteLogFile() - inFile := "dserver2.log" - csvFile := "dserver2.csv" + inFile := "dserver2.log.tmp" + csvFile := "dserver2.csv.tmp" expectedCsvFile := "dserver2.csv.expected" queryFile := fmt.Sprintf("%s.query", csvFile) expectedQueryFile := "dserver2.csv.query.expected" - ctx, cancel := context.WithCancel(context.Background()) + baseCtx, cancel := context.WithCancel(context.Background()) defer cancel() + ctx := WithTestLogger(baseCtx, testLogger) fd, err := os.Create(inFile) if err != nil { @@ -114,16 +115,12 @@ func TestDServer2(t *testing.T) { waitForCommand(ctx, t, stdoutCh, stderrCh, cmdErrCh) cancel() - if err := compareFiles(t, csvFile, expectedCsvFile); err != nil { + if err := compareFilesWithContext(ctx, t, csvFile, expectedCsvFile); err != nil { t.Error(err) return } - if err := compareFiles(t, queryFile, expectedQueryFile); err != nil { + if err := compareFilesWithContext(ctx, t, queryFile, expectedQueryFile); err != nil { t.Error(err) return } - - os.Remove(inFile) - os.Remove(csvFile) - os.Remove(queryFile) -} +}
\ No newline at end of file |
