Commits

Miki Tebeka committed e8549d4

handle no files

  • Participants
  • Parent commits 619a09e

Comments (0)

Files changed (3)

File data/gotest-nofiles.out

+?       alipay  [no test files]
+?       config  [no test files]
+=== RUN TestApp_AssetPath
+--- PASS: TestApp_AssetPath (0.00 seconds)
+=== RUN TestTrimTransferCeil
+--- PASS: TestTrimTransferCeil (0.00 seconds)
+=== RUN TestStatusDescription
+--- PASS: TestStatusDescription (0.00 seconds)
+=== RUN TestCode
+--- PASS: TestCode (0.00 seconds)
+PASS
+ok      controllers 0.024s
+?       controllers/api [no test files]
+?       controllers/bucket  [no test files]
+?       mail    [no test files]
+?       models  [no test files]
+?       plugins [no test files]
+?       templatefunc    [no test files]
+?       utils   [no test files]
+?       website [no test files]
 package main
 
 import (
+	"bufio"
 	"flag"
 	"fmt"
 	"io"
 	"log"
 	"os"
 	"regexp"
-	"bufio"
 	"strings"
 	"text/template"
 )
 	// ok  	_/home/miki/Projects/goroot/src/anotherTest	0.000s
 	gt_suiteRE = "^(ok|FAIL)[ \t]+([^ \t]+)[ \t]+(\\d+.\\d+)"
 
+	// ?       alipay  [no test files]
+	gt_noFiles = "^\\?.*\\[no test files\\]$"
+
 	// gocheck regular expressions
 
 	// START: mmath_test.go:16: MySuite.TestAdd
 	find_start := regexp.MustCompile(gt_startRE).FindStringSubmatch
 	find_end := regexp.MustCompile(gt_endRE).FindStringSubmatch
 	find_suite := regexp.MustCompile(gt_suiteRE).FindStringSubmatch
+	is_nofiles := regexp.MustCompile(gt_noFiles).MatchString
 	is_exit := regexp.MustCompile("^exit status -?\\d+").MatchString
 
 	suites := []*Suite{}
 	for lnum := 1; scanner.Scan(); lnum++ {
 		line := scanner.Text()
 
+		// TODO: Only ouside a suite/test, report as empty suite?
+		if is_nofiles(line) {
+			continue
+		}
+
 		tokens := find_start(line)
 		if tokens != nil {
 			if curTest != nil {

File go2xunit_test.go

 	}
 }
 
-func loadTests(filename string, t *testing.T) ([]*Suite, error) {
+func loadGotest(filename string, t *testing.T) ([]*Suite, error) {
 	file, err := os.Open(filename)
 	if err != nil {
 		t.Fatalf("can't open %s - %s", filename, err)
 
 func Test_parseOutput(t *testing.T) {
 	filename := "data/gotest.out"
-	suites, err := loadTests(filename, t)
+	suites, err := loadGotest(filename, t)
 	if err != nil {
 		t.Fatalf("error loading %s - %s", filename, err)
 	}
 }
 
 func Test_parseOutputBad(t *testing.T) {
-	_, err := loadTests("go2xunit.go", t)
+	_, err := loadGotest("go2xunit.go", t)
 	if err == nil {
 		t.Fatalf("managed to find suites in junk")
 	}
 		t.Fatalf("num failed differ %d != %d", suite.NumFailed(), nfailed)
 	}
 }
+
+func Test_NoFiles(t *testing.T) {
+	filename := "data/gotest-nofiles.out"
+	suites, err := loadGotest(filename, t)
+
+	if err != nil {
+		t.Fatalf("error loading %s - %s", filename, err)
+	}
+
+	count := 1
+	if len(suites) != count {
+		t.Fatalf("bad number of suites. expected %d got %d", count, len(suites))
+	}
+}