Skip to content

Commit

Permalink
feat: [XCTest] add cli argument --contains
Browse files Browse the repository at this point in the history
  • Loading branch information
electricbubble committed Apr 28, 2021
1 parent 6cfdad6 commit 9022c2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ $ gidevice forward -l=9100 -r=9100 -u=39xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx7

```shell
$ gidevice xctest com.leixipaopao.WebDriverAgentRunner.xctrunner
# Only the logs contained in the text are displayed
$ gidevice xctest com.leixipaopao.WebDriverAgentRunner.xctrunner --contains="ServerURLHere->" --contains="Running tests..." --contains="Built at"
```

#### Syslog
Expand Down
16 changes: 15 additions & 1 deletion cmd/xctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"os"
"os/signal"
"strings"
)

// xctestCmd represents the xctest command
Expand All @@ -20,6 +21,7 @@ var xctestCmd = &cobra.Command{
}
bundleID := args[0]
udid, _ := cmd.Flags().GetString("udid")
contains, _ := cmd.Flags().GetStringArray("contains")

d, err := internal.GetDeviceFromCommand(udid)
internal.ErrorExit(err)
Expand All @@ -33,7 +35,17 @@ var xctestCmd = &cobra.Command{

go func() {
for s := range out {
fmt.Print(s)
// show all
if len(contains) == 0 {
fmt.Print(s)
continue
}

for _, sub := range contains {
if strings.Contains(s, sub) {
fmt.Print(s)
}
}
}
done <- os.Interrupt
}()
Expand All @@ -48,5 +60,7 @@ var xctestCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(xctestCmd)

xctestCmd.Flags().StringArrayP("contains", "c", []string{}, "Only the logs contained in the text are displayed")

xctestCmd.Flags().StringP("udid", "u", "", "Device uuid")
}

0 comments on commit 9022c2c

Please sign in to comment.