mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
Add -root flag so tests can write artifacts to tmp
This commit is contained in:
parent
19ba0321b0
commit
3bc2342303
3 changed files with 15 additions and 4 deletions
|
@ -90,7 +90,11 @@ func UserHomeDir() string {
|
|||
}
|
||||
|
||||
func createDirs() {
|
||||
DenoDir = path.Join(UserHomeDir(), ".deno")
|
||||
if *flagRoot == "" {
|
||||
DenoDir = path.Join(UserHomeDir(), ".deno")
|
||||
} else {
|
||||
DenoDir = *flagRoot
|
||||
}
|
||||
CacheDir = path.Join(DenoDir, "cache")
|
||||
err := os.MkdirAll(CacheDir, 0700)
|
||||
check(err)
|
||||
|
|
|
@ -45,7 +45,7 @@ func listTestFiles() []string {
|
|||
return out
|
||||
}
|
||||
|
||||
func CheckOutput(t *testing.T, outFile string, denoFn string) {
|
||||
func checkOutput(t *testing.T, outFile string, denoFn string) {
|
||||
outFile = path.Join("testdata", outFile)
|
||||
jsFile := strings.TrimSuffix(outFile, ".out")
|
||||
|
||||
|
@ -54,7 +54,12 @@ func CheckOutput(t *testing.T, outFile string, denoFn string) {
|
|||
t.Fatal(err.Error())
|
||||
}
|
||||
|
||||
cmd := exec.Command(denoFn, jsFile, "--reload")
|
||||
dir, err := ioutil.TempDir("", "TestIntegration")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cmd := exec.Command(denoFn, "--root="+dir, jsFile)
|
||||
var out bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
err = cmd.Run()
|
||||
|
@ -80,7 +85,7 @@ func TestIntegration(t *testing.T) {
|
|||
outFiles := listTestFiles()
|
||||
for _, outFile := range outFiles {
|
||||
t.Run(outFile, func(t *testing.T) {
|
||||
CheckOutput(t, outFile, denoFn)
|
||||
checkOutput(t, outFile, denoFn)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
2
main.go
2
main.go
|
@ -13,6 +13,8 @@ var flagReload = flag.Bool("reload", false, "Reload cached remote source code.")
|
|||
var flagV8Options = flag.Bool("v8-options", false, "Print V8 command line options.")
|
||||
var flagDebug = flag.Bool("debug", false, "Enable debug output.")
|
||||
var flagGoProf = flag.String("goprof", "", "Write golang cpu profile to file.")
|
||||
var flagRoot = flag.String("root", "",
|
||||
"Where to cache compilation artifacts. Default: ~/.deno")
|
||||
|
||||
func stringAsset(path string) string {
|
||||
data, err := Asset("dist/" + path)
|
||||
|
|
Loading…
Reference in a new issue