dawn_node: Improve error handling for run-cts
Rebuild if the `out-node` directory is missing. Actually check the server's status code. Fix error handling for bad statuses. Change-Id: I2164bba528036d39f10852f4ffd8ace76f145dba Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/67780 Reviewed-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
38e7ce09a0
commit
32e9dd2dfd
|
@ -23,6 +23,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -174,7 +175,8 @@ func run() error {
|
||||||
return fmt.Errorf("failed to scan source files for modified timestamps: %w", err)
|
return fmt.Errorf("failed to scan source files for modified timestamps: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctsNeedsRebuild := mostRecentSourceChange.After(cache.BuildTimestamp)
|
ctsNeedsRebuild := mostRecentSourceChange.After(cache.BuildTimestamp) ||
|
||||||
|
!isDir(filepath.Join(r.cts, "out-node"))
|
||||||
if build {
|
if build {
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Println("CTS needs rebuild:", ctsNeedsRebuild)
|
fmt.Println("CTS needs rebuild:", ctsNeedsRebuild)
|
||||||
|
@ -491,6 +493,7 @@ func (r *runner) runServer(caseIndices <-chan int, results chan<- result) error
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if postResp.StatusCode == http.StatusOK {
|
||||||
var resp Response
|
var resp Response
|
||||||
if err := json.NewDecoder(postResp.Body).Decode(&resp); err != nil {
|
if err := json.NewDecoder(postResp.Body).Decode(&resp); err != nil {
|
||||||
res.error = fmt.Errorf("server response decode failure")
|
res.error = fmt.Errorf("server response decode failure")
|
||||||
|
@ -513,7 +516,16 @@ func (r *runner) runServer(caseIndices <-chan int, results chan<- result) error
|
||||||
res.status = skip
|
res.status = skip
|
||||||
res.message = resp.Message
|
res.message = resp.Message
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("unknown status: '%v'", resp.Status)
|
res.status = fail
|
||||||
|
res.error = fmt.Errorf("unknown status: '%v'", resp.Status)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
msg, err := ioutil.ReadAll(postResp.Body)
|
||||||
|
if err != nil {
|
||||||
|
msg = []byte(err.Error())
|
||||||
|
}
|
||||||
|
res.status = fail
|
||||||
|
res.error = fmt.Errorf("server error: %v", string(msg))
|
||||||
}
|
}
|
||||||
results <- res
|
results <- res
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue