mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
Use check() to improve error check (#139)
This commit is contained in:
parent
874db2a334
commit
8094c7421b
3 changed files with 8 additions and 21 deletions
|
@ -9,9 +9,7 @@ import (
|
|||
|
||||
func SetCacheDirForTest(prefix string) {
|
||||
dir, err := ioutil.TempDir("", prefix)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
check(err)
|
||||
CacheDir = dir
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
4
main.go
4
main.go
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue