util/testenv: add new package to hold InTest

Removes duplicated code.

Updates #cleanup

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2023-08-08 09:29:35 -07:00
committed by Maisem Ali
parent 3e255d76e1
commit 682fd72f7b
10 changed files with 53 additions and 25 deletions

View File

@ -12,7 +12,6 @@ import (
"crypto/tls"
"encoding/hex"
"errors"
"flag"
"fmt"
"io"
"log"
@ -53,12 +52,11 @@ import (
"tailscale.com/types/logid"
"tailscale.com/types/nettype"
"tailscale.com/util/mak"
"tailscale.com/util/testenv"
"tailscale.com/wgengine"
"tailscale.com/wgengine/netstack"
)
func inTest() bool { return flag.Lookup("test.v") != nil }
// Server is an embedded Tailscale server.
//
// Its exported fields may be changed until the first method call.
@ -605,7 +603,7 @@ func (s *Server) start() (reterr error) {
}
func (s *Server) startLogger(closePool *closeOnErrorPool) error {
if inTest() {
if testenv.InTest() {
return nil
}
cfgPath := filepath.Join(s.rootPath, "tailscaled.log.conf")