示例#1
0
func convertCoverage(in map[string][]core.LineCoverage) map[string]string {
	ret := map[string]string{}
	for k, v := range in {
		ret[k] = core.TestCoverageString(v)
	}
	return ret
}
示例#2
0
// Test the sample Python test output file.
func TestPythonResults(t *testing.T) {
	coverage, err := parseTestCoverage(target, pythonCoverageFile)
	if err != nil {
		t.Errorf("Failed to read coverage file %s", pythonCoverageFile)
	}
	if len(coverage.Files) != 4 {
		t.Errorf("Expected exactly four files covered by this test")
	}
	lines, present := coverage.Files["src/build/python/pex_test.py"]
	if !present {
		t.Errorf("Coverage info for src/build/python/pex_test.py not recorded.")
	}
	if len(lines) != 24 {
		t.Errorf("Expected exactly 24 lines of coverage information, was %d.", len(lines))
	}
	outputStr := core.TestCoverageString(lines)
	expected := "NNCNNCNCNCNCNNUNCNNCNNCU"
	if outputStr != expected {
		t.Errorf("Incorrect coverage output; was %s, expected %s", outputStr, expected)
	}
}
示例#3
0
// Test the sample Go test output file.
func TestGoResults(t *testing.T) {
	coverage, err := parseTestCoverage(target, goCoverageFile)
	if err != nil {
		t.Errorf("Failed to read coverage file %s", goCoverageFile)
	}
	if len(coverage.Files) != 7 {
		t.Errorf("Expected exactly seven files covered by this test")
	}
	lines, present := coverage.Files["src/core/file_label.go"]
	if !present {
		t.Errorf("Coverage info for src/core/file_label.go not recorded.")
	}
	if len(lines) != 55 {
		t.Errorf("Expected exactly 55 lines of coverage information, was %d.", len(lines))
	}
	outputStr := core.TestCoverageString(lines)
	expected := "NNNNNNNNNNNNNNNUUUNUUUNUUUNUUUNNNNNNNNNNUUUNUUUNUUUNUUU"
	if len(expected) != 55 {
		t.Errorf("oops, expected string is wrong")
	}
	if outputStr != expected {
		t.Errorf("Incorrect coverage output; was %s, expected %s", outputStr, expected)
	}
}