Skip to content

Commit

Permalink
v1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed May 29, 2022
1 parent 75a7e27 commit a742aaa
Showing 1 changed file with 34 additions and 35 deletions.
69 changes: 34 additions & 35 deletions cmd/wda.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"io"
"log"
"net"
"net/http"
"os"
"os/signal"
"strings"
Expand Down Expand Up @@ -100,40 +99,40 @@ var wdaCmd = &cobra.Command{
shutWdaDown <- os.Interrupt
}()

go func() {
var resp *http.Response
var httpErr error
var checkTime = 0
for {
time.Sleep(time.Duration(20) * time.Second)
checkTime++
resp, httpErr = http.Get(fmt.Sprintf("http://127.0.0.1:%d/status", serverLocalPort))
if httpErr != nil {
fmt.Printf("request fail: %s", httpErr)
continue
}
if resp.StatusCode == 200 {
fmt.Printf("wda server health checked %d times: ok\n", checkTime)
} else {
stopTest()
var upTimes = 0
for {
output, stopTest, err2 = device.XCTest(wdaBundleID, giDevice.WithXCTestEnv(testEnv))
upTimes++
if err2 != nil {
fmt.Printf("WebDriverAgent server start failed in %d times: %s\n", upTimes, err2)
if upTimes >= 3 {
fmt.Printf("WebDriverAgent server start failed more than 3 times, giving up...\n")
os.Exit(0)
}
} else {
break
}
}
}
}
defer resp.Body.Close()
}()
//go func() {
// var resp *http.Response
// var httpErr error
// var checkTime = 0
// for {
// time.Sleep(time.Duration(20) * time.Second)
// checkTime++
// resp, httpErr = http.Get(fmt.Sprintf("http://127.0.0.1:%d/status", serverLocalPort))
// if httpErr != nil {
// fmt.Printf("request fail: %s", httpErr)
// continue
// }
// if resp.StatusCode == 200 {
// fmt.Printf("wda server health checked %d times: ok\n", checkTime)
// } else {
// stopTest()
// var upTimes = 0
// for {
// output, stopTest, err2 = device.XCTest(wdaBundleID, giDevice.WithXCTestEnv(testEnv))
// upTimes++
// if err2 != nil {
// fmt.Printf("WebDriverAgent server start failed in %d times: %s\n", upTimes, err2)
// if upTimes >= 3 {
// fmt.Printf("WebDriverAgent server start failed more than 3 times, giving up...\n")
// os.Exit(0)
// }
// } else {
// break
// }
// }
// }
// }
// defer resp.Body.Close()
//}()

<-shutWdaDown
stopTest()
Expand Down

0 comments on commit a742aaa

Please sign in to comment.