test: set PYTHONPATH for image-info on travis
Create a GetImageInfoCommand analogous to GetOsbuildCommand that will adjust the PYTHONPATH for image-info on travis so that the osbuild python module is accessible.
This commit is contained in:
parent
84022a7889
commit
44f0ba368f
3 changed files with 21 additions and 2 deletions
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
package constants
|
||||
|
||||
import "os/exec"
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func GetOsbuildCommand(store, outputDirectory string) *exec.Cmd {
|
||||
cmd := exec.Command(
|
||||
|
|
@ -18,6 +21,15 @@ func GetOsbuildCommand(store, outputDirectory string) *exec.Cmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func GetImageInfoCommand(imagePath string) *exec.Cmd {
|
||||
cmd := exec.Command(
|
||||
"tools/image-info",
|
||||
imagePath,
|
||||
)
|
||||
cmd.Env = append(os.Environ(), "PYTHONPATH=osbuild")
|
||||
return cmd
|
||||
}
|
||||
|
||||
var TestPaths = struct {
|
||||
ImageInfo string
|
||||
PrivateKey string
|
||||
|
|
|
|||
|
|
@ -14,6 +14,13 @@ func GetOsbuildCommand(store, outputDirectory string) *exec.Cmd {
|
|||
)
|
||||
}
|
||||
|
||||
func GetImageInfoCommand(imagePath string) *exec.Cmd {
|
||||
return exec.Command(
|
||||
"/usr/libexec/osbuild-composer/image-info",
|
||||
imagePath,
|
||||
)
|
||||
}
|
||||
|
||||
var TestPaths = struct {
|
||||
ImageInfo string
|
||||
PrivateKey string
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func testImageInfo(t *testing.T, imagePath string, rawImageInfoExpected []byte)
|
|||
err := json.Unmarshal(rawImageInfoExpected, &imageInfoExpected)
|
||||
require.NoErrorf(t, err, "cannot decode expected image info: %#v", err)
|
||||
|
||||
cmd := exec.Command(constants.TestPaths.ImageInfo, imagePath)
|
||||
cmd := constants.GetImageInfoCommand(imagePath)
|
||||
cmd.Stderr = os.Stderr
|
||||
reader, writer := io.Pipe()
|
||||
cmd.Stdout = writer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue