Skip to content

Commit

Permalink
Use check() to improve error check (denoland#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijia Wang authored and ry committed Jun 5, 2018
1 parent 874db2a commit 8094c74
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
4 changes: 1 addition & 3 deletions deno_dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import (

func SetCacheDirForTest(prefix string) {
dir, err := ioutil.TempDir("", prefix)
if err != nil {
panic(err)
}
check(err)
CacheDir = dir
}

Expand Down
21 changes: 6 additions & 15 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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")
}
}
Expand Down
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 8094c74

Please sign in to comment.