rules.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package parser
  2. import "strings"
  3. func noGoFiles(line string) bool {
  4. return strings.HasPrefix(line, "can't load package: ") &&
  5. (strings.Contains(line, ": no buildable Go source files in ") ||
  6. strings.Contains(line, ": no Go ") ||
  7. strings.Contains(line, "cannot find module providing package"))
  8. }
  9. func buildFailed(line string) bool {
  10. return strings.HasPrefix(line, "# ") ||
  11. strings.Contains(line, "cannot find package") ||
  12. (strings.HasPrefix(line, "can't load package: ") && !strings.Contains(line, ": no Go ")) ||
  13. (strings.Contains(line, ": found packages ") && strings.Contains(line, ".go) and ") && strings.Contains(line, ".go) in "))
  14. }
  15. func noTestFunctions(line string) bool {
  16. return line == "testing: warning: no tests to run"
  17. }
  18. func noTestFiles(line string) bool {
  19. return strings.HasPrefix(line, "?") && strings.Contains(line, "[no test files]")
  20. }
  21. func isNewTest(line string) bool {
  22. return strings.HasPrefix(line, "=== ")
  23. }
  24. func isTestResult(line string) bool {
  25. return strings.HasPrefix(line, "--- FAIL:") || strings.HasPrefix(line, "--- PASS:") || strings.HasPrefix(line, "--- SKIP:")
  26. }
  27. func isPackageReport(line string) bool {
  28. return (strings.HasPrefix(line, "FAIL") ||
  29. strings.HasPrefix(line, "exit status") ||
  30. strings.HasPrefix(line, "PASS") ||
  31. isCoverageSummary(line) ||
  32. packagePassed(line))
  33. }
  34. func packageFailed(line string) bool {
  35. return strings.HasPrefix(line, "FAIL\t")
  36. }
  37. func packagePassed(line string) bool {
  38. return strings.HasPrefix(line, "ok \t")
  39. }
  40. func isCoverageSummary(line string) bool {
  41. return strings.HasPrefix(line, "coverage: ") && strings.Contains(line, "% of statements")
  42. }