Пример #1
0
// ShowTestDescription shows the description for the selected set of
// tests.
func ShowTestDescription(conf *tomlParser.Config, testPaths []string) {
	for _, testDir := range testPaths {
		testDescription, err := tomlParser.Parse(filepath.Join(testDir, "test_description.toml"),
			conf.IncludeDir)
		if err != nil {
			log.Printf("Error parsing test description in %s: %v", testDir, err)
			continue
		}
		fmt.Println("test name: ", path.Base(testDir))
		fmt.Println("--------------------------------------------------------------")
		fmt.Println(testDescription.Description)
		fmt.Println()
	}
}
Пример #2
0
// createSimJobs is responsible for filling a worker queue with
// jobs to be run via the simulation tool. It parses the test
// description, assembles a TestDescription struct and adds it
// to the simulation job queue.
func createSimJobs(includePath string, testPaths []string,
	simJobs chan *tester.TestData, testResults chan *tester.TestResult) {
	runID := 0
	for _, testDir := range testPaths {
		testFile := filepath.Join(testDir, "test_description.toml")
		testDescription, err := tomlParser.Parse(testFile, includePath)
		if err != nil {
			msg := fmt.Sprintf("Error parsing test description in %s: %v", testDir, err)
			testResults <- &tester.TestResult{Path: testFile, Success: false,
				TestName: "parse description", ErrorMessage: msg}
			continue
		}

		// create output directory
		outputDir := file.GetOutputDir(testDir)
		if err := os.Mkdir(outputDir, 0744); err != nil {
			msg := fmt.Sprint(err)
			testResults <- &tester.TestResult{Path: testFile, Success: false,
				TestName: "create test output directory", ErrorMessage: msg}
			continue
		}

		// set path and pick a Seed value for run
		testDescription.Path = testDir
		testDescription.Run.RunID = runID

		// schedule requested number of Seeds; if there is just a single
		// Seed requested we pick one randomly
		switch testDescription.Run.NumSeeds {
		case 0: // user didn't set number of Seeds -- assume single Seed
			testDescription.Run.NumSeeds = 1
			testDescription.Run.Seed = rng.Intn(10000)
		case 1:
			testDescription.Run.Seed = rng.Intn(10000)
		default:
			for i := 1; i < testDescription.Run.NumSeeds; i++ {
				newTest := testDescription.Copy()
				newTest.Run.Seed = i
				testDescription.Run.Seed = i + 1
				simJobs <- &tester.TestData{newTest, nil}
			}
		}
		simJobs <- &tester.TestData{testDescription, nil}
		runID++
	}
	close(simJobs)
}
Пример #3
0
// extractCategories extracts the available test categories from the provided
// test selection (x, x:y, 'all', etc.)
func extractCategories(conf *tomlParser.Config, testNames []string) map[string][]string {
	tests := extractAllTestCases(conf.TestDir, testNames)
	categoryMap := make(map[string][]string)
	for _, t := range tests {
		p, err := tomlParser.Parse(filepath.Join(t, "test_description.toml"), conf.IncludeDir)
		if err != nil {
			continue
		}
		for _, k := range p.KeyWords {
			if _, ok := categoryMap[k]; !ok {
				categoryMap[k] = []string{t}
			} else {
				categoryMap[k] = append(categoryMap[k], t)
			}
		}
	}
	return categoryMap
}