Skip to content

Commit

Permalink
Merge pull request #1241 from monopole/hackPluginTesting
Browse files Browse the repository at this point in the history
Hack for local testing of isolated plugins.
  • Loading branch information
monopole committed Jun 24, 2019
2 parents b878cd0 + 19c8e23 commit ae5ebcc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/kusttest/kusttestharness.go
Expand Up @@ -31,16 +31,16 @@ type KustTestHarness struct {
}

func NewKustTestHarness(t *testing.T, path string) *KustTestHarness {
return NewKustTestHarnessWithPluginConfig(
return newHarness(
t, path, plugins.DefaultPluginConfig())
}

func NewKustTestPluginHarness(t *testing.T, path string) *KustTestHarness {
return NewKustTestHarnessWithPluginConfig(
return newHarness(
t, path, plugins.ActivePluginConfig())
}

func NewKustTestHarnessWithPluginConfig(
func newHarness(
t *testing.T, path string,
pc *types.PluginConfig) *KustTestHarness {
return NewKustTestHarnessFull(t, path, loader.RestrictionRootOnly, pc)
Expand Down
12 changes: 9 additions & 3 deletions pkg/plugins/compiler.go
Expand Up @@ -41,7 +41,7 @@ type Compiler struct {
}

// DefaultSrcRoot guesses where the user
// has her ${g}/${v}/${k}.go files.
// has her ${g}/${v}/$lower(${k})/${k}.go files.
func DefaultSrcRoot() (string, error) {
var nope []string
var root string
Expand Down Expand Up @@ -109,8 +109,14 @@ func (b *Compiler) Compile(g, v, k string) error {
}
srcFile := filepath.Join(b.srcRoot, g, v, lowK, k) + ".go"
if !FileExists(srcFile) {
return fmt.Errorf(
"cannot find source %s", srcFile)
// Handy for tests of lone plugins.
s := k + ".go"
if !FileExists(s) {
return fmt.Errorf(
"cannot find source at '%s' or '%s'", srcFile, s)

}
srcFile = s
}
commands := []string{
"build",
Expand Down

0 comments on commit ae5ebcc

Please sign in to comment.