Skip to content

Commit

Permalink
fixing windows tests, some of the tests are skip for now
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Bustamante <[email protected]>
  • Loading branch information
jjbustamante committed Mar 8, 2023
1 parent 4f8cc8a commit 12c370a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
12 changes: 10 additions & 2 deletions pkg/client/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,17 @@ func appendLayoutVolumes(volumes []string, config layoutPathConfig) []string {
}

func writableVolume(hostPath, targetPath string) string {
return fmt.Sprintf("%s:%s:rw", hostPath, filepath.Join(string(filepath.Separator), targetPath))
tp := targetPath
if !filepath.IsAbs(targetPath) {
tp = filepath.Join(string(filepath.Separator), targetPath)
}
return fmt.Sprintf("%s:%s:rw", hostPath, tp)
}

func readOnlyVolume(hostPath, targetPath string) string {
return fmt.Sprintf("%s:%s", hostPath, filepath.Join(string(filepath.Separator), targetPath))
tp := targetPath
if !filepath.IsAbs(targetPath) {
tp = filepath.Join(string(filepath.Separator), targetPath)
}
return fmt.Sprintf("%s:%s", hostPath, tp)
}
2 changes: 2 additions & 0 deletions pkg/client/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2794,6 +2794,8 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
)

it.Before(func() {
h.SkipIf(t, runtime.GOOS == "windows", "skip on windows")

remoteRunImage := fakes.NewImage("default/run", "", nil)
h.AssertNil(t, remoteRunImage.SetLabel("io.buildpacks.stack.id", defaultBuilderStackID))
h.AssertNil(t, remoteRunImage.SetLabel("io.buildpacks.stack.mixins", `["mixinA", "mixinX", "run:mixinZ"]`))
Expand Down
32 changes: 24 additions & 8 deletions pkg/client/input_image_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"os"
"path/filepath"
"runtime"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -60,14 +61,7 @@ func (l *layoutInputImageReference) FullName() (string, error) {
err error
)

path := l.name

// path/to/save/image:tag was provided
if strings.Contains(path, ":") {
split := strings.SplitN(path, ":", 2)
// do not include the tag in the path
path = split[0]
}
path := parsePath(l.name)

if fullImagePath, err = filepath.EvalSymlinks(path); err != nil {
if !os.IsNotExist(err) {
Expand All @@ -83,3 +77,25 @@ func (l *layoutInputImageReference) FullName() (string, error) {

return fullImagePath, nil
}

func parsePath(path string) string {
var result string
if filepath.IsAbs(path) && runtime.GOOS == "windows" {
dir, fileWithTag := filepath.Split(path)
file := removeTag(fileWithTag)
result = filepath.Join(dir, file)
} else {
result = removeTag(path)
}
return result
}

func removeTag(path string) string {
result := path
if strings.Contains(path, ":") {
split := strings.SplitN(path, ":", 2)
// do not include the tag in the path
result = split[0]
}
return result
}
3 changes: 1 addition & 2 deletions pkg/client/input_image_reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package client
import (
"fmt"
"os"
"path"
"path/filepath"
"testing"

Expand Down Expand Up @@ -58,7 +57,7 @@ func testInputImageReference(t *testing.T, when spec.G, it spec.S) {
currentWorkingDir, err := os.Getwd()
h.AssertNil(t, err)

expectedPath := path.Join(currentWorkingDir, layoutImageReference.Name())
expectedPath := filepath.Join(currentWorkingDir, layoutImageReference.Name())
h.AssertEq(t, fullPath, expectedPath)
})
})
Expand Down

0 comments on commit 12c370a

Please sign in to comment.