Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uncomment failing windows tests #4042

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ jobs:
run: go test -cover ./...
working-directory: ./kyaml

# TODO: uncomment once Windows tests are passing.
# - name: Test api
# run: go test -cover ./... -ldflags "-X sigs.k8s.io/kustomize/api/provenance.version=v444.333.222"
# working-directory: ./api
- name: Test api
run: go test -cover ./... -ldflags "-X sigs.k8s.io/kustomize/api/provenance.version=v444.333.222"
working-directory: ./api

- name: Test cmd/config
run: go test -cover ./...
Expand Down
3 changes: 2 additions & 1 deletion api/internal/git/repospec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package git
import (
"fmt"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
Expand All @@ -19,7 +20,7 @@ import (
// in various outputs (especially tests). Not using an
// actual directory name here, as that's a temporary directory
// with a unique name that isn't created until clone time.
const notCloned = filesys.ConfirmedDir("/notCloned")
const notCloned = filesys.ConfirmedDir(string(os.PathSeparator) + "notCloned")

// RepoSpec specifies a git repository and a branch and path therein.
type RepoSpec struct {
Expand Down
20 changes: 14 additions & 6 deletions api/internal/git/repospec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ package git

import (
"fmt"
"path/filepath"
"os"
"path"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -37,9 +38,9 @@ var hostNamesRawAndNormalized = [][]string{
{"[email protected]/", "[email protected]:"},
}

func makeUrl(hostFmt, orgRepo, path, href string) string {
if len(path) > 0 {
orgRepo = filepath.Join(orgRepo, path)
func makeUrl(hostFmt, orgRepo, p, href string) string {
if len(p) > 0 {
orgRepo = path.Join(orgRepo, p)
}
url := hostFmt + orgRepo
if href != "" {
Expand All @@ -59,7 +60,7 @@ func TestNewRepoSpecFromUrl(t *testing.T) {
uri := makeUrl(hostRaw, orgRepo, pathName, hrefArg)
rs, err := NewRepoSpecFromUrl(uri)
if err != nil {
t.Errorf("problem %v", err)
t.Errorf("problem: %v, url: %s", err, uri)
}
if rs.Host != hostSpec {
bad = append(bad, []string{"host", uri, rs.Host, hostSpec})
Expand Down Expand Up @@ -90,13 +91,20 @@ func TestNewRepoSpecFromUrl(t *testing.T) {
}

var badData = [][]string{
{"/tmp", "uri looks like abs path"},
{absPrefix() + "tmp", "uri looks like abs path"},
{"iauhsdiuashduas", "url lacks orgRepo"},
{"htxxxtp://github.com/", "url lacks host"},
{"ssh://git.example.com", "url lacks orgRepo"},
{"git::___", "url lacks orgRepo"},
}

func absPrefix() string {
if os.PathSeparator == '\\' {
return "C:\\"
}
return string(os.PathSeparator)
}

func TestNewRepoSpecFromUrlErrors(t *testing.T) {
for _, tuple := range badData {
_, err := NewRepoSpecFromUrl(tuple[0])
Expand Down
2 changes: 2 additions & 0 deletions api/internal/plugins/compiler/compiler_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0

// +build !windows

package compiler_test

import (
Expand Down
2 changes: 1 addition & 1 deletion api/internal/plugins/execplugin/execplugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ s/$BAR/bar baz/g
yaml)
require.NoError(t, err)

expected := "someteam.example.com/v1/sedtransformer/SedTransformer"
expected := filepath.Join("someteam.example.com", "v1", "sedtransformer", "SedTransformer")
if !strings.HasSuffix(p.Path(), expected) {
t.Fatalf("expected suffix '%s', got '%s'", expected, p.Path())
}
Expand Down
2 changes: 2 additions & 0 deletions api/internal/plugins/loader/loader_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0

// +build !windows

package loader_test

import (
Expand Down
5 changes: 3 additions & 2 deletions api/internal/target/kusttarget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package target_test

import (
"encoding/base64"
"os"
"reflect"
"testing"

Expand Down Expand Up @@ -77,10 +78,10 @@ commonLabels:
}

kt := makeKustTargetWithRf(
t, th.GetFSys(), "/", provider.NewDefaultDepProvider())
t, th.GetFSys(), string(os.PathSeparator), provider.NewDefaultDepProvider())
for tn, tc := range testCases {
t.Run(tn, func(t *testing.T) {
th.WriteK("/", tc.content)
th.WriteK(string(os.PathSeparator), tc.content)
err := kt.Load()
if tc.errContains != "" {
require.NotNilf(t, err, "expected error containing: `%s`", tc.errContains)
Expand Down
4 changes: 3 additions & 1 deletion api/internal/utils/pathsplitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

package utils

import "strings"
import (
"strings"
)

// TODO: Move these to kyaml

Expand Down
4 changes: 2 additions & 2 deletions api/kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"bytes"
"fmt"
"os"
"path"
"path/filepath"
"strings"
"unicode"
"unicode/utf8"
Expand Down Expand Up @@ -183,7 +183,7 @@ func parseFileSource(source string) (keyName, filePath string, err error) {
numSeparators := strings.Count(source, "=")
switch {
case numSeparators == 0:
return path.Base(source), source, nil
return filepath.Base(source), source, nil
case numSeparators == 1 && strings.HasPrefix(source, "="):
return "", "", fmt.Errorf("key name for file path %v missing", strings.TrimPrefix(source, "="))
case numSeparators == 1 && strings.HasSuffix(source, "="):
Expand Down