-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_runner.go
More file actions
38 lines (30 loc) · 752 Bytes
/
test_runner.go
File metadata and controls
38 lines (30 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fmt"
"os"
"os/exec"
)
func main() {
fmt.Println("Running all tests for prerender-url-shortener...")
// Run tests with coverage
cmd := exec.Command("go", "test", "-v", "-cover", "./...")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
fmt.Printf("Tests failed: %v\n", err)
os.Exit(1)
}
fmt.Println("\nAll tests passed!")
// Run benchmarks
fmt.Println("\nRunning benchmarks...")
benchCmd := exec.Command("go", "test", "-bench=.", "-benchmem", "./...")
benchCmd.Stdout = os.Stdout
benchCmd.Stderr = os.Stderr
err = benchCmd.Run()
if err != nil {
fmt.Printf("Benchmarks failed: %v\n", err)
// Don't exit on benchmark failure
}
fmt.Println("\nTest run complete!")
}