Skip to content

Commit

Permalink
feat: [XCTest] add cli argument --env
Browse files Browse the repository at this point in the history
  • Loading branch information
electricbubble committed May 18, 2021
1 parent 9022c2c commit d80c0e6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ $ gidevice forward -l=9100 -r=9100 -u=39xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx7
$ 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"
$ gidevice xctest com.leixipaopao.WebDriverAgentRunner.xctrunner --env=USE_PORT=8200 --env=MJPEG_SERVER_PORT=9200
```

#### Syslog
Expand Down
14 changes: 13 additions & 1 deletion cmd/xctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"errors"
"fmt"
giDevice "github.com/electricbubble/gidevice"
"github.com/electricbubble/gidevice-cli/internal"
"github.com/spf13/cobra"
"log"
Expand All @@ -23,10 +24,20 @@ var xctestCmd = &cobra.Command{
udid, _ := cmd.Flags().GetString("udid")
contains, _ := cmd.Flags().GetStringArray("contains")

rawEnv, _ := cmd.Flags().GetStringArray("env")
appEnv := make(map[string]interface{})
if len(rawEnv) != 0 {
for _, pairingValue := range rawEnv {
kv := strings.Split(pairingValue, "=")
appEnv[kv[0]] = kv[1]
}
log.Println("Process environment:", appEnv)
}

d, err := internal.GetDeviceFromCommand(udid)
internal.ErrorExit(err)

out, cancel, err := d.XCTest(bundleID)
out, cancel, err := d.XCTest(bundleID, giDevice.WithXCTestEnv(appEnv))
internal.ErrorExit(err)

done := make(chan os.Signal, 1)
Expand Down Expand Up @@ -61,6 +72,7 @@ func init() {
rootCmd.AddCommand(xctestCmd)

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

xctestCmd.Flags().StringP("udid", "u", "", "Device uuid")
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/electricbubble/gidevice-cli
go 1.16

require (
github.com/electricbubble/gidevice v0.3.0
github.com/electricbubble/gidevice v0.3.2
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.7.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/electricbubble/gidevice v0.3.0 h1:7BviJ3frVmV1iIBRl1max2oDczTQ6H7XwsqSHgGiwjI=
github.com/electricbubble/gidevice v0.3.0/go.mod h1:hWRHIPf4uyiEB56hnVHVvu6MoVg7RlJY8ZV2FVgLKZA=
github.com/electricbubble/gidevice v0.3.2 h1:s//oKXaC8hihiu3EYoaPwnyKfrmaEPxMVXjoXxRXb78=
github.com/electricbubble/gidevice v0.3.2/go.mod h1:hWRHIPf4uyiEB56hnVHVvu6MoVg7RlJY8ZV2FVgLKZA=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down

0 comments on commit d80c0e6

Please sign in to comment.