Skip to content

Commit

Permalink
test: redirect output of test to test.log (OpenAtomFoundation#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
longfar-ncy authored Jan 13, 2024
1 parent 1b1e5da commit 386860d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ make_config.mk
logs/
lib/
output/
*.log

# DB
db/
Expand Down
13 changes: 10 additions & 3 deletions tests/util/pikiwidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,15 @@ func StartServer(config string, options map[string]string, delete bool) *Server
b := getBinPath()
c := exec.Command(b)

c.Stdout = os.Stdout
c.Stderr = os.Stderr
outfile, err := os.Create("test.log")
if err != nil {
panic(err)
}
defer outfile.Close()

c.Stdout = outfile
c.Stderr = outfile
log.SetOutput(outfile)

if len(config) != 0 {
t := time.Now().UnixMilli()
Expand Down Expand Up @@ -182,7 +189,7 @@ func StartServer(config string, options map[string]string, delete bool) *Server
p, _ = strconv.Atoi(options["port"])
}

err := c.Start()
err = c.Start()
if err != nil {
log.Println("pikiwidb startup failed.", err.Error())
return nil
Expand Down

0 comments on commit 386860d

Please sign in to comment.