1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

Use check() to improve error check (#139)

This commit is contained in:
Weijia Wang 2018-06-05 16:07:40 +08:00 committed by Ryan Dahl
parent 874db2a334
commit 8094c7421b
3 changed files with 8 additions and 21 deletions

View file

@ -9,9 +9,7 @@ import (
func SetCacheDirForTest(prefix string) {
dir, err := ioutil.TempDir("", prefix)
if err != nil {
panic(err)
}
check(err)
CacheDir = dir
}

View file

@ -21,22 +21,17 @@ var denoFn string
// so if the server runs on a different port, it will fail.
func startServer() {
l, err := net.Listen("tcp", ":4545")
if err != nil {
panic(err)
}
check(err)
rootHandler := http.FileServer(http.Dir("."))
go func() {
if err := http.Serve(l, rootHandler); err != nil {
panic(err)
}
err := http.Serve(l, rootHandler)
check(err)
}()
}
func listTestFiles() []string {
files, err := ioutil.ReadDir("testdata")
if err != nil {
panic(err)
}
check(err)
out := make([]string, 0)
for _, file := range files {
fn := file.Name()
@ -72,9 +67,7 @@ func checkOutput(t *testing.T, outFile string, shouldSucceed bool) {
func deno(inputFn string) (actual []byte, cachedir string, err error) {
cachedir, err = ioutil.TempDir("", "TestIntegration")
if err != nil {
panic(err)
}
check(err)
cmd := exec.Command(denoFn, "--cachedir="+cachedir, inputFn)
var out bytes.Buffer
@ -89,9 +82,7 @@ func integrationTestSetup() {
if denoFn == "" {
startServer()
cwd, err := os.Getwd()
if err != nil {
panic(err)
}
check(err)
denoFn = path.Join(cwd, "deno")
}
}

View file

@ -76,9 +76,7 @@ func Init() {
// Use --prof for profiling JS.
if *flagGoProf != "" {
f, err := os.Create(*flagGoProf)
if err != nil {
panic(err)
}
check(err)
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}