Skip to content

Commit 55b03b1

Browse files
authored
OAS-10663 Add Timestamps to the test output for go-driver (#663)
Use with ADD_TIMESTAMP=true
1 parent 7408745 commit 55b03b1

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

Makefile

+6-4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ else
148148
DOCKER_V2_RUN_CMD := $(GOV2IMAGE) go test -timeout 120m $(GOBUILDTAGSOPT) $(TESTOPTIONS) $(TESTVERBOSEOPTIONS) -parallel $(TESTV2PARALLEL) ./tests
149149
endif
150150

151+
ifeq ("$(ADD_TIMESTAMP)", "true")
152+
ADD_TIMESTAMP :=| go run ./test/timestamp_output/timestamp_output.go
153+
endif
154+
151155
.PHONY: all build clean linter run-tests vulncheck
152156

153157
all: build
@@ -435,8 +439,7 @@ DOCKER_V1_CMD_PARAMS=\
435439
-w /usr/code/
436440

437441
__test_go_test:
438-
$(DOCKER_CMD) $(DOCKER_V1_CMD_PARAMS) $(DOCKER_RUN_CMD) \
439-
&& echo "success!" \
442+
($(DOCKER_CMD) $(DOCKER_V1_CMD_PARAMS) $(DOCKER_RUN_CMD) $(ADD_TIMESTAMP)) && echo "success!" \
440443
|| ( $(ON_FAILURE_PARAMS) MAJOR_VERSION=1 . ./test/on_failure.sh)
441444

442445

@@ -449,8 +452,7 @@ DOCKER_CMD_V2_PARAMS=\
449452
-w /usr/code/v2/
450453

451454
__test_v2_go_test:
452-
$(DOCKER_CMD) $(DOCKER_CMD_V2_PARAMS) $(DOCKER_V2_RUN_CMD) \
453-
&& echo "success!" \
455+
($(DOCKER_CMD) $(DOCKER_CMD_V2_PARAMS) $(DOCKER_V2_RUN_CMD) $(ADD_TIMESTAMP)) && echo "success!" \
454456
|| ($(ON_FAILURE_PARAMS) MAJOR_VERSION=2 . ./test/on_failure.sh)
455457

456458
__test_debug__:
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2025 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package main
22+
23+
import (
24+
"bufio"
25+
"fmt"
26+
"os"
27+
"time"
28+
)
29+
30+
func main() {
31+
scanner := bufio.NewScanner(os.Stdin)
32+
for scanner.Scan() {
33+
now := time.Now()
34+
nsec := now.Nanosecond()
35+
36+
// Format only once at compile-time and reuse
37+
fmt.Printf("%d-%02d-%02d %02d:%02d:%02d.%09d| %s\n",
38+
now.Year(), now.Month(), now.Day(),
39+
now.Hour(), now.Minute(), now.Second(),
40+
nsec, scanner.Text(),
41+
)
42+
}
43+
}

0 commit comments

Comments
 (0)