- Issue #4: currently there is no official release yet so we cant download from installer - I added an installer debugger here to test (f091dbf13bdf109b631951e2558651f560ca8b84) - Issue #5: my another library [fuzzy](https://github.com/versenilvis/fuzzy/) has a logic bug so it causes crash, fix d479c6cb4d8453e50366c9839daaabb45a98a2df - Other: - remove unneeded comments (edd9d05fdd16e682b6b416913e2fa9c3f6599956) - Add some tests - Fix reload crash (3a76e78e655fd8daafb635ec0937667325f75ee4) - New optimized build command (56a4a815f836271b861f32795d2df3b25a3dffc0)
This commit is contained in:
@@ -2,6 +2,7 @@ package tests
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/versenilvis/iris/commands/core"
|
||||
@@ -31,21 +32,13 @@ func TestLookup(t *testing.T) {
|
||||
minResults int
|
||||
mustContain string
|
||||
}{
|
||||
// REQUIREMENT: Token 1, no trailing space -> top-level suggestions
|
||||
{"Top-level", "gi", 1, "git"},
|
||||
// REQUIREMENT: Token 1, with trailing space -> subcommand suggestions
|
||||
{"Subcommand", "git ", 1, "git commit"},
|
||||
// REQUIREMENT: Alias expansion (gca -> git commit -a)
|
||||
{"Alias expansion", "gca", 1, "git commit -a"},
|
||||
// REQUIREMENT: Alias value with space (ta -> tmux a -t)
|
||||
{"Alias with space", "ta", 1, "tmux a -t"},
|
||||
// REQUIREMENT: Subcommand depth 2+ (git remote add)
|
||||
{"Deep subcommand", "git remote ", 1, "git remote add"},
|
||||
// REQUIREMENT: Option dedup (do not suggest --verbose if already typed)
|
||||
{"Option dedup", "git --verbose -", 0, ""},
|
||||
// REQUIREMENT: --flag=value does not count into argCount
|
||||
{"Option dedup", "git --verbose -", 0, ""},
|
||||
{"Flag with value ignore", "git --output=json ", 2, "git --output=json commit"},
|
||||
// REQUIREMENT: Unknown root command -> nil
|
||||
{"Unknown root command", "unknowncmd ", 0, ""},
|
||||
}
|
||||
|
||||
@@ -70,3 +63,33 @@ func TestLookup(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLookupConcurrent(t *testing.T) {
|
||||
core.Registry = make(map[string]*core.Spec)
|
||||
core.Register(&core.Spec{
|
||||
Name: "git",
|
||||
Subcommands: []core.Subcommand{
|
||||
{Name: "commit", Options: []core.Option{{Name: "--message"}}, MaxArgs: 1},
|
||||
},
|
||||
})
|
||||
|
||||
core.ShellAliases = map[string]string{
|
||||
"gca": "git commit -a",
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
const goroutines = 10
|
||||
const iterations = 50
|
||||
|
||||
for range goroutines {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for range iterations {
|
||||
_ = core.Lookup("gca")
|
||||
_ = core.Lookup("git ")
|
||||
}
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user