summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-04-22 20:44:06 +0200
committerewy <ewy0@protonmail.com>2026-04-22 20:44:06 +0200
commit086a0cc0eb75c0c3a15cf6a715427df1e2d589a2 (patch)
tree0bcc881b202f94a7ea39f94f13aea89ca2046312
parentc6a362a039b1662dfc0badeb8badc4458e446787 (diff)
slowly working on that test coverage
-rw-r--r--.pik/web/update.sh2
-rw-r--r--cache/cache.go22
-rw-r--r--cache/cache_test.go29
-rw-r--r--crawl/crawl.go6
-rw-r--r--crawl/crawl_test.go39
-rw-r--r--describe/describe.go23
-rw-r--r--describe/describe_test.go88
-rw-r--r--search/search.go4
-rw-r--r--web/coverage.html134
9 files changed, 274 insertions, 73 deletions
diff --git a/.pik/web/update.sh b/.pik/web/update.sh
index 4e6788c..62d41a9 100644
--- a/.pik/web/update.sh
+++ b/.pik/web/update.sh
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
# update files on website
set -euo pipefail
-ssh git@ewy.one -- cd /srv/pik/pik "&&" .pik/web/web.sh \ No newline at end of file
+ssh git@ewy.one -- cd /srv/pik/pik "&&" bash .pik/web/web.sh \ No newline at end of file
diff --git a/cache/cache.go b/cache/cache.go
index f036052..c51acbc 100644
--- a/cache/cache.go
+++ b/cache/cache.go
@@ -34,6 +34,8 @@ type Entry struct {
Label string
}
+var Empty = Cache{}
+
// Path is the file path to the "contexts" cache file
var Path = path.Join(paths.Cache, "contexts")
@@ -42,9 +44,11 @@ var FsPath = Path[1:]
var UnexpectedEntryError = errors.New("unexpected cache entry")
+// LoadFile creates a Cache from a file or an empty one if the file does not exist
+// this handles opening a reader for Unmarshal
func LoadFile(root fs.FS, path string) (Cache, error) {
fd, err := root.Open(path)
- if errors.Is(err, os.ErrNotExist) {
+ if errors.Is(err, fs.ErrNotExist) {
return Cache{}, nil
} else if err != nil {
return Cache{}, err
@@ -52,10 +56,11 @@ func LoadFile(root fs.FS, path string) (Cache, error) {
if fd != nil {
defer fd.Close()
}
- return Load(fd)
+ return Unmarshal(fd)
}
-func Load(r io.Reader) (Cache, error) {
+// Unmarshal attempts to create a Cache from reader content
+func Unmarshal(r io.Reader) (Cache, error) {
c := Cache{}
scanner := bufio.NewScanner(r)
for scanner.Scan() {
@@ -80,7 +85,8 @@ func Load(r io.Reader) (Cache, error) {
return c, nil
}
-func (c Cache) String() string {
+// Marshal returns the file representation of the Cache
+func (c Cache) Marshal() []byte {
b := strings.Builder{}
for _, e := range c.Entries {
b.WriteString(e.Path)
@@ -88,7 +94,11 @@ func (c Cache) String() string {
b.WriteString(e.Label)
b.WriteString("\n")
}
- return b.String()
+ return []byte(b.String())
+}
+
+func (c Cache) String() string {
+ return string(c.Marshal())
}
func New(st *model.State) Cache {
@@ -115,7 +125,7 @@ func SaveFile(path string, s *model.State, loaded Cache) error {
func Save(s *model.State, w io.Writer, loaded Cache) error {
result := New(s).Merge(loaded)
- _, err := w.Write([]byte(result.String()))
+ _, err := w.Write([]byte(result.Marshal()))
return err
}
diff --git a/cache/cache_test.go b/cache/cache_test.go
index 38c100a..1a9c46d 100644
--- a/cache/cache_test.go
+++ b/cache/cache_test.go
@@ -4,6 +4,7 @@ package cache
import (
"github.com/stretchr/testify/assert"
+ "path/filepath"
. "pik/testx"
"strings"
"testing"
@@ -36,7 +37,7 @@ func TestFromReader_Blank(t *testing.T) {
input := `
`
sr := strings.NewReader(input)
- c, err := Load(sr)
+ c, err := Unmarshal(sr)
assert.Nil(t, err)
assert.Len(t, c.Entries, 0)
}
@@ -44,7 +45,7 @@ func TestFromReader_Blank(t *testing.T) {
func TestFromReader_OneEntry(t *testing.T) {
input := `/abc/def # deffers`
sr := strings.NewReader(input)
- c, err := Load(sr)
+ c, err := Unmarshal(sr)
assert.Nil(t, err)
assert.Len(t, c.Entries, 1)
assert.Equal(t, c.Entries[0], Entry{
@@ -59,7 +60,7 @@ func TestFromReader_ManyEntries(t *testing.T) {
/path/src # da source
`
sr := strings.NewReader(input)
- c, err := Load(sr)
+ c, err := Unmarshal(sr)
assert.Nil(t, err)
assert.Len(t, c.Entries, 3)
assert.Equal(t, c.Entries[0], Entry{
@@ -87,7 +88,7 @@ func TestFromReader_Comments(t *testing.T) {
# // comment
`
sr := strings.NewReader(input)
- c, err := Load(sr)
+ c, err := Unmarshal(sr)
assert.Nil(t, err)
assert.Len(t, c.Entries, 3)
assert.Equal(t, c.Entries[0], Entry{
@@ -162,6 +163,24 @@ func TestLoadFile_NotExist(t *testing.T) {
f := fstest.MapFS{}
c, err := LoadFile(f, "anything is fine")
assert.Nil(t, c.Entries)
- assert.Error(t, err)
+ assert.NoError(t, err)
+
+}
+func TestSaveFile(t *testing.T) {
+ dir := t.TempDir()
+ loc := filepath.Join(dir, "savefile")
+ st := TState(TSource("source_one", "target"), TSource("second_source", "t1", "t2", "t3"))
+ c := Cache{Entries: []Entry{
+ {
+ Path: "path",
+ Label: "label",
+ },
+ {
+ Path: "/otherpath/123",
+ Label: "",
+ },
+ }}
+ err := SaveFile(loc, st, c)
+ assert.NoError(t, err)
}
diff --git a/crawl/crawl.go b/crawl/crawl.go
index dac6b19..fccd81d 100644
--- a/crawl/crawl.go
+++ b/crawl/crawl.go
@@ -16,12 +16,8 @@ func RichLocations(origin string) []string {
eval, err := Evaluated(origin)
if err == nil && eval != origin {
- i := 0
evaledLocations := Locations(eval)
- var result []string
- for i < len(locs) && i < len(evaledLocations) {
- result = append(result, evaledLocations[i], locs[i])
- }
+ result := append(locs, evaledLocations...)
result = slices.Compact(result)
return result
}
diff --git a/crawl/crawl_test.go b/crawl/crawl_test.go
index 88b70f1..27fc0e8 100644
--- a/crawl/crawl_test.go
+++ b/crawl/crawl_test.go
@@ -1,8 +1,12 @@
+//go:build test
+
package crawl
import (
"github.com/stretchr/testify/assert"
- "io/fs"
+ "os"
+ "path/filepath"
+ "strings"
"testing"
)
@@ -53,6 +57,35 @@ func TestLocations_HighestFirst(t *testing.T) {
assert.Equal(t, locs[0], "/one/two/three")
}
-func Test(t *testing.T) {
- assert.True(t, fs.ValidPath("asdf/hjkl"))
+func TestRichLocations(t *testing.T) {
+ dir := t.TempDir()
+ targetPath := filepath.Join(dir, "target")
+ linkPath := filepath.Join(dir, "link")
+
+ innerPath := filepath.Join(targetPath, "inner")
+ innerLinkPath := filepath.Join(linkPath, "inner")
+ err := os.Mkdir(targetPath, 0777)
+ assert.NoError(t, err)
+ err = os.Symlink(targetPath, linkPath)
+ assert.NoError(t, err)
+ err = os.Mkdir(innerPath, 0777)
+ result := RichLocations(innerLinkPath)
+ assert.NotNil(t, result)
+ var hasLink, hasTarget = false, false
+ for _, e := range result {
+ if strings.HasSuffix(e, "target/inner") {
+ hasTarget = true
+ continue
+ }
+ if strings.HasSuffix(e, "link/inner") {
+ hasLink = true
+ continue
+ }
+ }
+ if !hasLink {
+ t.Fatal("evaluated link subdirectories were not included")
+ }
+ if !hasTarget {
+ t.Fatal("original target subdirectories were not included")
+ }
}
diff --git a/describe/describe.go b/describe/describe.go
index 443c0e6..0863b6d 100644
--- a/describe/describe.go
+++ b/describe/describe.go
@@ -2,6 +2,7 @@ package describe
import (
"bufio"
+ "io"
"os"
"pik/model"
"strings"
@@ -25,7 +26,17 @@ func Describe(key model.Target, file string) (string, error) {
return "", err
}
defer fd.Close()
- scanner := bufio.NewScanner(fd)
+ text, err := FromReader(fd)
+ if err != nil {
+ return text, err
+ } else {
+ descriptions[key] = &text
+ }
+ return text, err
+}
+
+func FromReader(reader io.Reader) (string, error) {
+ scanner := bufio.NewScanner(reader)
scanner.Split(bufio.ScanLines)
scanner.Scan()
text := scanner.Text()
@@ -34,13 +45,19 @@ func Describe(key model.Target, file string) (string, error) {
text = scanner.Text()
}
text = strings.TrimSpace(text)
- if !strings.HasPrefix(text, "#") {
+ hasPrefix := false
+ for _, p := range DescriptionPrefixes {
+ if strings.HasPrefix(text, p) {
+ hasPrefix = true
+ break
+ }
+ }
+ if !hasPrefix {
return "", nil
}
for _, c := range DescriptionPrefixes {
text = strings.TrimPrefix(text, c)
text = strings.TrimSpace(text)
}
- descriptions[key] = &text
return text, nil
}
diff --git a/describe/describe_test.go b/describe/describe_test.go
new file mode 100644
index 0000000..283be64
--- /dev/null
+++ b/describe/describe_test.go
@@ -0,0 +1,88 @@
+//go:build test
+
+package describe
+
+import (
+ "github.com/stretchr/testify/assert"
+ "os"
+ "path/filepath"
+ "pik/runner"
+ "testing"
+)
+
+type key struct {
+ *runner.Stub
+}
+
+func Key() *key {
+ return &key{
+ Stub: &runner.Stub{},
+ }
+}
+
+func TestDescribe(t *testing.T) {
+ dir := t.TempDir()
+ f := filepath.Join(dir, "file")
+ err := os.WriteFile(f, []byte("# this is a comment"), 0666)
+ assert.NoError(t, err)
+ result, err := Describe(Key(), f)
+ assert.NoError(t, err)
+ assert.Contains(t, result, "this is a comment")
+}
+
+func TestDescribe_Slashes(t *testing.T) {
+ dir := t.TempDir()
+ f := filepath.Join(dir, "file")
+ err := os.WriteFile(f, []byte(" // this is a comment"), 0666)
+ assert.NoError(t, err)
+ result, err := Describe(Key(), f)
+ assert.NoError(t, err)
+ assert.Contains(t, result, "this is a comment")
+}
+
+func TestDescribe_Cache(t *testing.T) {
+ dir := t.TempDir()
+ f := filepath.Join(dir, "file")
+ k := Key()
+ err := os.WriteFile(f, []byte(" // this is a comment"), 0666)
+ assert.NoError(t, err)
+ result, err := Describe(k, f)
+ assert.NoError(t, err)
+ assert.Contains(t, result, "this is a comment")
+ err = os.Remove(f)
+ if err != nil {
+ assert.NoError(t, err)
+ }
+ cached, err := Describe(k, f)
+ assert.NoError(t, err)
+ assert.Equal(t, result, cached)
+
+}
+
+func TestDescribe_NoDescription(t *testing.T) {
+ dir := t.TempDir()
+ f := filepath.Join(dir, "file")
+ err := os.WriteFile(f, []byte("1230987324091823740918237409283"), 0666)
+ assert.NoError(t, err)
+ result, err := Describe(Key(), f)
+ assert.NoError(t, err)
+ assert.Empty(t, result)
+}
+
+func TestDescribe_Shebang_NoDescription(t *testing.T) {
+ dir := t.TempDir()
+ f := filepath.Join(dir, "file")
+ err := os.WriteFile(f, []byte("#!/usr/bin/env bash\nkjausdhuahsdf"), 0666)
+ assert.NoError(t, err)
+ result, err := Describe(Key(), f)
+ assert.Empty(t, result)
+ assert.NoError(t, err)
+}
+
+func TestDescribe_Error(t *testing.T) {
+ dir := t.TempDir()
+ f := filepath.Join(dir, "file")
+ result, err := Describe(Key(), f)
+ assert.Empty(t, result)
+ assert.Error(t, err)
+}
diff --git a/search/search.go b/search/search.go
index 767473d..fd06ab5 100644
--- a/search/search.go
+++ b/search/search.go
@@ -89,10 +89,10 @@ args_loop:
}
- if target == nil {
+ if target == nil && suspect == nil {
subdir = append(subdir, arg)
continue args_loop
- } else if targetSource != nil {
+ } else if targetSource != nil || suspect != nil {
forward = append(forward, arg)
continue args_loop
}
diff --git a/web/coverage.html b/web/coverage.html
index 39f19bf..44d8836 100644
--- a/web/coverage.html
+++ b/web/coverage.html
@@ -55,11 +55,11 @@
<div id="nav">
<select id="files">
- <option value="file0">pik/cache/cache.go (75.4%)</option>
+ <option value="file0">pik/cache/cache.go (88.7%)</option>
- <option value="file1">pik/crawl/crawl.go (53.8%)</option>
+ <option value="file1">pik/crawl/crawl.go (95.7%)</option>
- <option value="file2">pik/describe/describe.go (0.0%)</option>
+ <option value="file2">pik/describe/describe.go (96.9%)</option>
<option value="file3">pik/env/env.go (0.0%)</option>
@@ -69,7 +69,7 @@
<option value="file6">pik/indexers/pikdex/hydrate.go (0.0%)</option>
- <option value="file7">pik/indexers/pikdex/index.go (11.7%)</option>
+ <option value="file7">pik/indexers/pikdex/index.go (11.3%)</option>
<option value="file8">pik/indexers/pikdex/meta.go (0.0%)</option>
@@ -129,7 +129,7 @@
<option value="file36">pik/runner/stub.go (0.0%)</option>
- <option value="file37">pik/search/search.go (94.6%)</option>
+ <option value="file37">pik/search/search.go (93.5%)</option>
<option value="file38">pik/testx/create.go (70.0%)</option>
@@ -181,6 +181,8 @@ type Entry struct {
Label string
}
+var Empty = Cache{}
+
// Path is the file path to the "contexts" cache file
var Path = path.Join(paths.Cache, "contexts")
@@ -189,9 +191,11 @@ var FsPath = Path[1:]
var UnexpectedEntryError = errors.New("unexpected cache entry")
+// LoadFile creates a Cache from a file or an empty one if the file does not exist
+// this handles opening a reader for Unmarshal
func LoadFile(root fs.FS, path string) (Cache, error) <span class="cov8" title="1">{
fd, err := root.Open(path)
- if errors.Is(err, os.ErrNotExist) </span><span class="cov8" title="1">{
+ if errors.Is(err, fs.ErrNotExist) </span><span class="cov8" title="1">{
return Cache{}, nil
}</span> else<span class="cov8" title="1"> if err != nil </span><span class="cov0" title="0">{
return Cache{}, err
@@ -199,10 +203,11 @@ func LoadFile(root fs.FS, path string) (Cache, error) <span class="cov8" title="
<span class="cov8" title="1">if fd != nil </span><span class="cov8" title="1">{
defer fd.Close()
}</span>
- <span class="cov8" title="1">return Load(fd)</span>
+ <span class="cov8" title="1">return Unmarshal(fd)</span>
}
-func Load(r io.Reader) (Cache, error) <span class="cov8" title="1">{
+// Unmarshal attempts to create a Cache from reader content
+func Unmarshal(r io.Reader) (Cache, error) <span class="cov8" title="1">{
c := Cache{}
scanner := bufio.NewScanner(r)
for scanner.Scan() </span><span class="cov8" title="1">{
@@ -227,7 +232,8 @@ func Load(r io.Reader) (Cache, error) <span class="cov8" title="1">{
<span class="cov8" title="1">return c, nil</span>
}
-func (c Cache) String() string <span class="cov8" title="1">{
+// Marshal returns the file representation of the Cache
+func (c Cache) Marshal() []byte <span class="cov8" title="1">{
b := strings.Builder{}
for _, e := range c.Entries </span><span class="cov8" title="1">{
b.WriteString(e.Path)
@@ -235,9 +241,13 @@ func (c Cache) String() string <span class="cov8" title="1">{
b.WriteString(e.Label)
b.WriteString("\n")
}</span>
- <span class="cov8" title="1">return b.String()</span>
+ <span class="cov8" title="1">return []byte(b.String())</span>
}
+func (c Cache) String() string <span class="cov8" title="1">{
+ return string(c.Marshal())
+}</span>
+
func New(st *model.State) Cache <span class="cov8" title="1">{
c := &amp;Cache{}
for _, s := range st.Sources </span><span class="cov8" title="1">{
@@ -249,20 +259,20 @@ func New(st *model.State) Cache <span class="cov8" title="1">{
<span class="cov8" title="1">return *c</span>
}
-func SaveFile(path string, s *model.State, loaded Cache) error <span class="cov0" title="0">{
+func SaveFile(path string, s *model.State, loaded Cache) error <span class="cov8" title="1">{
fd, err := os.Create(path)
if err != nil </span><span class="cov0" title="0">{
return err
}</span>
- <span class="cov0" title="0">if fd != nil </span><span class="cov0" title="0">{
+ <span class="cov8" title="1">if fd != nil </span><span class="cov8" title="1">{
defer fd.Close()
}</span>
- <span class="cov0" title="0">return Save(s, fd, loaded)</span>
+ <span class="cov8" title="1">return Save(s, fd, loaded)</span>
}
-func Save(s *model.State, w io.Writer, loaded Cache) error <span class="cov0" title="0">{
+func Save(s *model.State, w io.Writer, loaded Cache) error <span class="cov8" title="1">{
result := New(s).Merge(loaded)
- _, err := w.Write([]byte(result.String()))
+ _, err := w.Write([]byte(result.Marshal()))
return err
}</span>
@@ -301,24 +311,20 @@ import (
"strings"
)
-func Evaluated(loc string) (string, error) <span class="cov0" title="0">{
+func Evaluated(loc string) (string, error) <span class="cov8" title="1">{
return filepath.EvalSymlinks(loc)
}</span>
-func RichLocations(origin string) []string <span class="cov0" title="0">{
+func RichLocations(origin string) []string <span class="cov8" title="1">{
locs := Locations(origin)
eval, err := Evaluated(origin)
- if err == nil &amp;&amp; eval != origin </span><span class="cov0" title="0">{
- i := 0
+ if err == nil &amp;&amp; eval != origin </span><span class="cov8" title="1">{
evaledLocations := Locations(eval)
- var result []string
- for i &lt; len(locs) &amp;&amp; i &lt; len(evaledLocations) </span><span class="cov0" title="0">{
- result = append(result, evaledLocations[i], locs[i])
- }</span>
- <span class="cov0" title="0">result = slices.Compact(result)
- return result</span>
- }
+ result := append(locs, evaledLocations...)
+ result = slices.Compact(result)
+ return result
+ }</span>
<span class="cov0" title="0">return locs</span>
}
@@ -352,6 +358,7 @@ func ParentDir(origin string) string <span class="cov8" title="1">{
import (
"bufio"
+ "io"
"os"
"pik/model"
"strings"
@@ -364,35 +371,51 @@ var DescriptionPrefixes = []string{
var descriptions = make(map[model.Target]*string)
-func Describe(key model.Target, file string) (string, error) <span class="cov0" title="0">{
- if d := descriptions[key]; d != nil </span><span class="cov0" title="0">{
+func Describe(key model.Target, file string) (string, error) <span class="cov8" title="1">{
+ if d := descriptions[key]; d != nil </span><span class="cov8" title="1">{
return *d, nil
}</span>
- <span class="cov0" title="0">fd, err := os.Open(file)
- if err != nil </span><span class="cov0" title="0">{
+ <span class="cov8" title="1">fd, err := os.Open(file)
+ if err != nil </span><span class="cov8" title="1">{
msg := err.Error()
descriptions[key] = &amp;msg
return "", err
}</span>
- <span class="cov0" title="0">defer fd.Close()
- scanner := bufio.NewScanner(fd)
+ <span class="cov8" title="1">defer fd.Close()
+ text, err := FromReader(fd)
+ if err != nil </span><span class="cov0" title="0">{
+ return text, err
+ }</span> else<span class="cov8" title="1"> {
+ descriptions[key] = &amp;text
+ }</span>
+ <span class="cov8" title="1">return text, err</span>
+}
+
+func FromReader(reader io.Reader) (string, error) <span class="cov8" title="1">{
+ scanner := bufio.NewScanner(reader)
scanner.Split(bufio.ScanLines)
scanner.Scan()
text := scanner.Text()
- if strings.HasPrefix(text, "#!") </span><span class="cov0" title="0">{
+ if strings.HasPrefix(text, "#!") </span><span class="cov8" title="1">{
scanner.Scan()
text = scanner.Text()
}</span>
- <span class="cov0" title="0">text = strings.TrimSpace(text)
- if !strings.HasPrefix(text, "#") </span><span class="cov0" title="0">{
+ <span class="cov8" title="1">text = strings.TrimSpace(text)
+ hasPrefix := false
+ for _, p := range DescriptionPrefixes </span><span class="cov8" title="1">{
+ if strings.HasPrefix(text, p) </span><span class="cov8" title="1">{
+ hasPrefix = true
+ break</span>
+ }
+ }
+ <span class="cov8" title="1">if !hasPrefix </span><span class="cov8" title="1">{
return "", nil
}</span>
- <span class="cov0" title="0">for _, c := range DescriptionPrefixes </span><span class="cov0" title="0">{
+ <span class="cov8" title="1">for _, c := range DescriptionPrefixes </span><span class="cov8" title="1">{
text = strings.TrimPrefix(text, c)
text = strings.TrimSpace(text)
}</span>
- <span class="cov0" title="0">descriptions[key] = &amp;text
- return text, nil</span>
+ <span class="cov8" title="1">return text, nil</span>
}
</pre>
@@ -692,7 +715,9 @@ func (u *pikdex) Index(absPath string, f fs.FS, runners []model.Runner) ([]model
return nil, err
}</span>
<span class="cov0" title="0">var targets []model.Target
+ u.Lock()
mod := u.mods[absPath]
+ u.Unlock()
if mod == nil </span><span class="cov0" title="0">{
u.mods[absPath] = &amp;SourceData{
Path: absPath,
@@ -2977,23 +3002,28 @@ func Search(s *model.State, args ...string) *Result <span class="cov8" title="1"
var suspectSource *model.Source
args_loop:
- for _, arg := range args </span><span class="cov8" title="1">{
+ for i, arg := range args </span><span class="cov8" title="1">{
for _, src := range s.Sources </span><span class="cov8" title="1">{
if targetSource == nil </span><span class="cov8" title="1">{
if src.Is(arg) </span><span class="cov8" title="1">{
targetSource = src
+ // only try to find the default target if this is the last argument
+ if len(args)-1 != i </span><span class="cov8" title="1">{
+ continue args_loop</span>
+ }
+
// try to look for arg target with the same name as the source
// "default target" of sorts
- for _, t := range targetSource.Targets </span><span class="cov8" title="1">{
+ <span class="cov8" title="1">for _, t := range targetSource.Targets </span><span class="cov8" title="1">{
if t.Matches(arg) </span><span class="cov8" title="1">{
target = t
continue args_loop</span>
}
}
- <span class="cov8" title="1">continue args_loop</span>
+ <span class="cov0" title="0">continue args_loop</span>
}
}
@@ -3002,9 +3032,14 @@ args_loop:
// uncertain about source, check ours to see if any match
for _, t := range src.Targets </span><span class="cov8" title="1">{
if t.Matches(arg) </span><span class="cov8" title="1">{
- target = t
- targetSource = src
- continue args_loop</span>
+ if slices.Equal(t.Sub(), subdir) </span><span class="cov8" title="1">{
+ target = t
+ targetSource = src
+ }</span> else<span class="cov8" title="1"> {
+ suspect = t
+ suspectSource = src
+ }</span>
+ <span class="cov8" title="1">continue args_loop</span>
}
}
@@ -3030,10 +3065,10 @@ args_loop:
}
- <span class="cov8" title="1">if target == nil </span><span class="cov8" title="1">{
+ <span class="cov8" title="1">if target == nil &amp;&amp; suspect == nil </span><span class="cov8" title="1">{
subdir = append(subdir, arg)
continue args_loop</span>
- } else<span class="cov8" title="1"> if targetSource != nil </span><span class="cov8" title="1">{
+ } else<span class="cov8" title="1"> if targetSource != nil || suspect != nil </span><span class="cov8" title="1">{
forward = append(forward, arg)
continue args_loop</span>
}
@@ -3042,8 +3077,11 @@ args_loop:
<span class="cov8" title="1">if suspect != nil &amp;&amp; target == nil </span><span class="cov8" title="1">{
target = suspect
targetSource = suspectSource
- confirm = true
- }</span>
+
+ if !(suspect.Sub() != nil &amp;&amp; subdir == nil) </span><span class="cov8" title="1">{
+ confirm = true
+ }</span>
+ }
<span class="cov8" title="1">if target != nil &amp;&amp; target.Sub() != nil &amp;&amp; subdir != nil &amp;&amp; !slices.Equal(target.Sub(), subdir) </span><span class="cov8" title="1">{
confirm = true