// runTestsViaRunner runs all the tests at the given source path via the runner. func runTestsViaRunner(runner TestRunner, path string) bool { log.Printf("Starting test run of %s via %v runner", path, runner.Title()) // Run setup for the runner. err := runner.SetupIfNecessary() if err != nil { errHighlight := color.New(color.FgRed, color.Bold) errHighlight.Print("ERROR: ") text := color.New(color.FgWhite) text.Printf("Could not setup %s runner: %v\n", runner.Title(), err) return false } // Iterate over each test file in the source path. For each, compile the code into // JS at a temporary location and then pass the temporary location to the test // runner. return compilerutil.WalkSourcePath(path, func(currentPath string, info os.FileInfo) (bool, error) { if !strings.HasSuffix(info.Name(), "_test"+parser.SERULIAN_FILE_EXTENSION) { return false, nil } success, err := buildAndRunTests(currentPath, runner) if err != nil { return true, err } if success { return true, nil } else { return true, fmt.Errorf("Failure in test of file %s", currentPath) } }) }
// formatFiles runs formatting of all matching source files found at the given source path. func formatFiles(path string, importHandling importHandlingInfo, debug bool) bool { return compilerutil.WalkSourcePath(path, func(currentPath string, info os.FileInfo) (bool, error) { if !strings.HasSuffix(info.Name(), parser.SERULIAN_FILE_EXTENSION) { return false, nil } return true, parseAndFormatSourceFile(currentPath, info, importHandling) }) }