Skip to content

Commit

Permalink
WIP: Fix test loading logic with symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
travier committed Nov 16, 2022
1 parent 13a775b commit eb38d96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions mantle/cmd/kola/kola.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ func runList(cmd *cobra.Command, args []string) error {
}
var testlist []*item
for name, test := range register.Tests {
// fmt.Printf("Looking at test: %s\n", name)
item := &item{
name,
test.Platforms,
Expand Down
14 changes: 13 additions & 1 deletion mantle/kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -1151,19 +1151,30 @@ func registerTestDir(dir, testprefix string, children []os.DirEntry) error {
executables := []string{}
for _, c := range children {
fpath := filepath.Join(dir, c.Name())
fmt.Printf("Looking at: %s\n", fpath)

info, err := c.Info()
if err != nil {
return errors.Wrapf(err, "c.Info %s", c.Name())
}

// follow symlinks; oddly, there's no IsSymlink()
// Note: we currently don't support nested symlinks
if info.Mode()&os.ModeSymlink != 0 {
info, err = os.Stat(fpath)
fmt.Printf("Found symlink: %s\n", c.Name())
dest, err := os.Readlink(fpath)
if err != nil {
return errors.Wrapf(err, "could not resolve symlink: %s", fpath)
}
resolved := filepath.Join(dir, dest)
fmt.Printf("Resolved: %s\n", resolved)
info, err = os.Stat(resolved)
if err != nil {
return errors.Wrapf(err, "stat %s", fpath)
}
fmt.Printf("Info: %s\n", info)
}
// fmt.Printf("Info: %s\n", info)
isreg := info.Mode().IsRegular()
if isreg && (info.Mode().Perm()&0001) > 0 {
executables = append(executables, filepath.Join(dir, c.Name()))
Expand Down Expand Up @@ -1193,6 +1204,7 @@ func registerTestDir(dir, testprefix string, children []os.DirEntry) error {
return errors.Wrapf(err, "parsing %s", fpath)
}
} else if c.IsDir() && c.Name() == kolaExtBinDataName {
fmt.Printf("Found dir: %s\n", c.Name())
dependencydir = filepath.Join(dir, c.Name())
} else if info.Mode()&os.ModeSymlink != 0 && c.Name() == kolaExtBinDataName {
target, err := filepath.EvalSymlinks(filepath.Join(dir, c.Name()))
Expand Down

0 comments on commit eb38d96

Please sign in to comment.