Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 8761df3

Browse files
Merge pull request #75 from r2d4/parallel
Run tests in parallel, dont use working dir
2 parents e9a49f8 + 83e6720 commit 8761df3

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

cmd/analyze.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ func analyzeImage(imageArg string, analyzerArgs []string) error {
9494
outputResults(analyses)
9595

9696
if save {
97-
dir, _ := os.Getwd()
98-
glog.Infof("Image was saved at %s as %s", dir, image.FSPath)
97+
glog.Infof("Image was saved at %s", image.FSPath)
9998
}
10099

101100
return nil

cmd/diff.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ func diffImages(image1Arg, image2Arg string, diffArgs []string) error {
110110
outputResults(diffs)
111111

112112
if save {
113-
dir, _ := os.Getwd()
114-
glog.Infof("Images were saved at %s as %s and %s", dir, imageMap[image1Arg].FSPath,
113+
glog.Infof("Images were saved at %s and %s", imageMap[image1Arg].FSPath,
115114
imageMap[image2Arg].FSPath)
116115

117116
}

tests/integration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func TestDiffAndAnalysis(t *testing.T) {
162162
}
163163
for _, test := range tests {
164164
t.Run(test.description, func(t *testing.T) {
165+
t.Parallel()
165166
args := []string{test.subcommand, test.imageA}
166167
if test.imageB != "" {
167168
args = append(args, test.imageB)

utils/image_prep_utils.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ func (p CloudPrepper) getFileSystem() (string, error) {
127127
URLPattern := regexp.MustCompile("^.+/(.+(:.+){0,1})$")
128128
URLMatch := URLPattern.FindStringSubmatch(p.Source)
129129
// Removing the ":" so that the image path name can be <image><tag>
130-
path := strings.Replace(URLMatch[1], ":", "", -1)
130+
sanitizedName := strings.Replace(URLMatch[1], ":", "", -1)
131+
132+
path, err := ioutil.TempDir("", sanitizedName)
133+
if err != nil {
134+
return "", err
135+
}
136+
131137
ref, err := docker.ParseReference("//" + p.Source)
132138
if err != nil {
133139
return "", err
@@ -146,10 +152,6 @@ func (p CloudPrepper) getFileSystem() (string, error) {
146152
return "", err
147153
}
148154

149-
if _, ok := os.Stat(path); ok != nil {
150-
os.MkdirAll(path, 0777)
151-
}
152-
153155
for _, b := range img.LayerInfos() {
154156
bi, _, err := imgSrc.GetBlob(b)
155157
if err != nil {

0 commit comments

Comments
 (0)