Skip to content

Commit aa8f801

Browse files
committed
Add test command
1 parent be37bc7 commit aa8f801

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
dist/
2+
kyx

main.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ package main
33
import (
44
"fmt"
55
"os"
6+
"path/filepath"
67
"slices"
78
"time"
89

910
"github.com/SoureCode/kyx/commands"
11+
"github.com/SoureCode/kyx/project"
12+
"github.com/SoureCode/kyx/shell"
1013
"github.com/SoureCode/kyx/tools"
1114
"github.com/pkg/errors"
1215
"github.com/symfony-cli/console"
@@ -31,6 +34,7 @@ var (
3134

3235
func main() {
3336
cmds := append(commands.GetCommands(), tools.GetCommands(toolsMapping)...)
37+
cmds = append(cmds, tools.CreateCommand("test"))
3438
toolNames := tools.GetNames(toolsMapping)
3539

3640
args := os.Args
@@ -46,6 +50,33 @@ func main() {
4650
os.Exit(0)
4751
}
4852

53+
if len(args) >= 2 && args[1] == "test" {
54+
p := project.GetProject()
55+
pd := p.GetDirectory()
56+
57+
if p.HasDevDependency("symfony/phpunit-bridge") {
58+
cmd := shell.NewPHPCommand(append([]string{filepath.Join(pd, "vendor", "bin", "simple-phpunit")}, args[2:]...)...).WithPassthrough()
59+
60+
if err := cmd.Run(); err != nil {
61+
fmt.Fprintf(os.Stderr, "Error executing simple-phpunit: %v\n", err)
62+
os.Exit(cmd.ExitCode())
63+
}
64+
65+
os.Exit(0)
66+
} else if p.HasDevDependency("phpunit/phpunit") {
67+
cmd := shell.NewPHPCommand(append([]string{filepath.Join(pd, "vendor", "bin", "phpunit")}, args[2:]...)...).WithPassthrough()
68+
69+
if err := cmd.Run(); err != nil {
70+
fmt.Fprintf(os.Stderr, "Error executing phpunit: %v\n", err)
71+
os.Exit(cmd.ExitCode())
72+
}
73+
74+
os.Exit(0)
75+
}
76+
77+
os.Exit(0)
78+
}
79+
4980
app := &console.Application{
5081
Name: "kyx",
5182
Usage: "kyx [command] [options]",

0 commit comments

Comments
 (0)