2019-01-11 11:00:12 +00:00
|
|
|
// Copyright 2015 The go-python Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
2021-08-30 05:32:08 +00:00
|
|
|
//go:build windows
|
2019-01-11 11:00:12 +00:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-08-30 05:32:08 +00:00
|
|
|
|
|
|
|
testEnvironment = os.Environ()
|
|
|
|
|
2019-01-16 09:28:59 +00:00
|
|
|
var (
|
2021-08-30 05:32:08 +00:00
|
|
|
// py2 = "python2"
|
|
|
|
py3 = "python3"
|
|
|
|
// pypy2 = "pypy"
|
|
|
|
// pypy3 = "pypy3"
|
2019-01-16 09:28:59 +00:00
|
|
|
)
|
|
|
|
|
2021-08-30 05:32:08 +00:00
|
|
|
if os.Getenv("GOPY_TRAVIS_CI") == "1" {
|
|
|
|
log.Printf("Running in travis CI")
|
2019-01-11 11:00:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
2019-01-16 09:28:59 +00:00
|
|
|
disabled []string
|
|
|
|
missing int
|
2019-01-11 11:00:12 +00:00
|
|
|
)
|
|
|
|
for _, be := range []struct {
|
2019-01-16 09:28:59 +00:00
|
|
|
name string
|
|
|
|
vm string
|
|
|
|
module string
|
|
|
|
mandatory bool
|
2019-01-11 11:00:12 +00:00
|
|
|
}{
|
2021-08-30 05:32:08 +00:00
|
|
|
{"py3", py3, "", true},
|
|
|
|
// {"py2", py2, "", true},
|
2019-01-11 11:00:12 +00:00
|
|
|
} {
|
|
|
|
args := []string{"-c", ""}
|
|
|
|
if be.module != "" {
|
|
|
|
args[1] = "import " + be.module
|
|
|
|
}
|
|
|
|
log.Printf("checking testbackend: %q...", be.name)
|
2021-08-30 05:32:08 +00:00
|
|
|
|
|
|
|
py, err := exec.LookPath(be.vm)
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("gopy: could not locate 'python' executable (err: %v)", err)
|
|
|
|
} else {
|
|
|
|
log.Printf("python executable found at: %s\n", py)
|
|
|
|
cmd := exec.Command(py, args...)
|
|
|
|
cmd.Stdin = os.Stdin
|
|
|
|
cmd.Stdout = os.Stdout
|
|
|
|
cmd.Stderr = os.Stderr
|
|
|
|
err = cmd.Run()
|
|
|
|
}
|
2019-01-11 11:00:12 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Printf("disabling testbackend: %q, error: '%s'", be.name, err.Error())
|
|
|
|
testBackends[be.name] = ""
|
|
|
|
disabled = append(disabled, be.name)
|
2019-01-16 09:28:59 +00:00
|
|
|
if be.mandatory {
|
|
|
|
missing++
|
|
|
|
}
|
2019-01-11 11:00:12 +00:00
|
|
|
} else {
|
|
|
|
log.Printf("enabling testbackend: %q", be.name)
|
|
|
|
testBackends[be.name] = be.vm
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(disabled) > 0 {
|
|
|
|
log.Printf("The following test backends are not available: %s",
|
|
|
|
strings.Join(disabled, ", "))
|
2021-08-30 05:32:08 +00:00
|
|
|
if os.Getenv("GOPY_TRAVIS_CI") == "1" && missing > 0 {
|
|
|
|
log.Fatalf("Not all backends available in travis CI")
|
2019-01-11 11:00:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|