]> ruderich.org/simon Gitweb - safcm/safcm.git/commitdiff
remote: tests: hide testRunner functions in test output
authorSimon Ruderich <simon@ruderich.org>
Sun, 9 May 2021 18:44:02 +0000 (20:44 +0200)
committerSimon Ruderich <simon@ruderich.org>
Sun, 9 May 2021 18:44:02 +0000 (20:44 +0200)
This is not perfect because they are called from files like
cmd/safcm-remote/sync/commands.go which is not very helpful to figure
out which test case failed. However, it's better than showing
cmd/safcm-remote/sync/sync_test.go which was the previous behavior.

cmd/safcm-remote/sync/sync_test.go

index 52d7435eadcea20abff6fbbc2f9e33639878692d..8ee14593148dc5b48eb95bc4f7e9ba31dd44eabc 100644 (file)
@@ -54,6 +54,8 @@ func (r *testRunner) Run(cmd *exec.Cmd) error {
        return resErr
 }
 func (r *testRunner) CombinedOutput(cmd *exec.Cmd) ([]byte, error) {
        return resErr
 }
 func (r *testRunner) CombinedOutput(cmd *exec.Cmd) ([]byte, error) {
+       r.t.Helper()
+
        stdout, stderr, err := r.check("combinedOutput", cmd)
        if stderr != nil {
                // stdout also contains stderr
        stdout, stderr, err := r.check("combinedOutput", cmd)
        if stderr != nil {
                // stdout also contains stderr
@@ -63,6 +65,7 @@ func (r *testRunner) CombinedOutput(cmd *exec.Cmd) ([]byte, error) {
 }
 func (r *testRunner) check(method string, cmd *exec.Cmd) (
        []byte, []byte, error) {
 }
 func (r *testRunner) check(method string, cmd *exec.Cmd) (
        []byte, []byte, error) {
+       r.t.Helper()
 
        if len(r.expCmds) == 0 {
                r.t.Fatalf("%s: empty expCmds", method)
 
        if len(r.expCmds) == 0 {
                r.t.Fatalf("%s: empty expCmds", method)
@@ -133,6 +136,8 @@ func prepareSync(req safcm.MsgSyncReq, runner *testRunner) (
 }
 
 func (s *syncTestResult) Wait() []string {
 }
 
 func (s *syncTestResult) Wait() []string {
+       s.runner.t.Helper()
+
        close(s.ch)
        s.wg.Wait()
 
        close(s.ch)
        s.wg.Wait()