mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 12:16: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() {
|
func createDirs() {
|
||||||
|
if *flagRoot == "" {
|
||||||
DenoDir = path.Join(UserHomeDir(), ".deno")
|
DenoDir = path.Join(UserHomeDir(), ".deno")
|
||||||
|
} else {
|
||||||
|
DenoDir = *flagRoot
|
||||||
|
}
|
||||||
CacheDir = path.Join(DenoDir, "cache")
|
CacheDir = path.Join(DenoDir, "cache")
|
||||||
err := os.MkdirAll(CacheDir, 0700)
|
err := os.MkdirAll(CacheDir, 0700)
|
||||||
check(err)
|
check(err)
|
||||||
|
|
|
@ -45,7 +45,7 @@ func listTestFiles() []string {
|
||||||
return out
|
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)
|
outFile = path.Join("testdata", outFile)
|
||||||
jsFile := strings.TrimSuffix(outFile, ".out")
|
jsFile := strings.TrimSuffix(outFile, ".out")
|
||||||
|
|
||||||
|
@ -54,7 +54,12 @@ func CheckOutput(t *testing.T, outFile string, denoFn string) {
|
||||||
t.Fatal(err.Error())
|
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
|
var out bytes.Buffer
|
||||||
cmd.Stdout = &out
|
cmd.Stdout = &out
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
|
@ -80,7 +85,7 @@ func TestIntegration(t *testing.T) {
|
||||||
outFiles := listTestFiles()
|
outFiles := listTestFiles()
|
||||||
for _, outFile := range outFiles {
|
for _, outFile := range outFiles {
|
||||||
t.Run(outFile, func(t *testing.T) {
|
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 flagV8Options = flag.Bool("v8-options", false, "Print V8 command line options.")
|
||||||
var flagDebug = flag.Bool("debug", false, "Enable debug output.")
|
var flagDebug = flag.Bool("debug", false, "Enable debug output.")
|
||||||
var flagGoProf = flag.String("goprof", "", "Write golang cpu profile to file.")
|
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 {
|
func stringAsset(path string) string {
|
||||||
data, err := Asset("dist/" + path)
|
data, err := Asset("dist/" + path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue