本文整理汇总了C++中CKernel::getTestSuiteMetricPluginManager方法的典型用法代码示例。如果您正苦于以下问题:C++ CKernel::getTestSuiteMetricPluginManager方法的具体用法?C++ CKernel::getTestSuiteMetricPluginManager怎么用?C++ CKernel::getTestSuiteMetricPluginManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKernel
的用法示例。
在下文中一共展示了CKernel::getTestSuiteMetricPluginManager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculateMetric
void calculateMetric(CSelectionData *selectionData, const std::string &name, rapidjson::Document &results)
{
ITestSuiteMetricPlugin *metric = kernel.getTestSuiteMetricPluginManager().getPlugin(name);
StringVector dependencies = metric->getDependency();
for (StringVector::iterator it = dependencies.begin(); it != dependencies.end(); it++) {
if (metricsCalculated.find(*it) == metricsCalculated.end()) {
calculateMetric(selectionData, *it, results);
}
}
(std::cerr << "[INFO] Calculating metrics: " << metric->getName() << " ...").flush();
metric->init(selectionData, &clusterList, revision);
metric->calculate(results);
metricsCalculated.insert(name);
(std::cerr << " done." << std::endl).flush();
}
示例2: main
int main(int argc, char* argv[]) {
std::cout << "test-suite-metrics (SoDA tool)" << std::endl;
options_description desc("Options");
desc.add_options()
("help,h", "Prints help message")
("create-json-file,j", "Creates a sample json file")
("list-cluster-algorithms,c", "Lists the cluster algorithms")
("list-metric-plugins,m", "Lists the metric plugins");
variables_map vm;
store(parse_command_line(argc, argv, desc), vm);
notify(vm);
if (argc < 2) {
std::cerr << "[ERROR] There are no arguments!" << std::endl;
printHelp();
return 1;
}
if (vm.count("help")) {
printHelp();
std::cout << desc << std::endl;
return 0;
}
if (vm.count("list-cluster-algorithms")) {
printPluginNames("cluster", kernel.getTestSuiteClusterPluginManager().getPluginNames());
return 0;
}
if (vm.count("list-metric-plugins")) {
printPluginNames("metric", kernel.getTestSuiteMetricPluginManager().getPluginNames());
return 0;
}
if (vm.count("create-json-file")) {
createJsonFile();
return 0;
}
return loadJsonFiles(String(argv[1]));
}
示例3: processJsonFiles
void processJsonFiles(String path)
{
try {
std::cout << "[INFO] Processing " << path << " configuration file." << std::endl;
rapidjson::Document reader;
{
FILE *in = fopen (path.c_str(), "r");
char readBuffer[65536];
rapidjson::FileReadStream is(in, readBuffer, sizeof(readBuffer));
reader.ParseStream<0, rapidjson::UTF8<>, rapidjson::FileReadStream>(is);
fclose(in);
}
boost::filesystem::path jsonPath(path);
std::string clusterAlgorithmName = reader["cluster-algorithm"].GetString();
ITestSuiteClusterPlugin *clusterAlgorithm = kernel.getTestSuiteClusterPluginManager().getPlugin(clusterAlgorithmName);
clusterAlgorithm->init(reader);
CSelectionData *selectionData = new CSelectionData();
StringVector metrics;
for (rapidjson::Value::ConstValueIterator itr = reader["metrics"].Begin(); itr != reader["metrics"].End(); ++itr)
metrics.push_back(itr->GetString());
if (metrics.empty()) {
std::cerr << "[ERROR] Missing metrics parameter in config file " << path << "." << std::endl;
return;
} else {
for (StringVector::const_iterator it = metrics.begin(); it != metrics.end(); ++it) {
try {
kernel.getTestSuiteMetricPluginManager().getPlugin(*it);
} catch (std::out_of_range &e) {
std::cerr << "[ERROR] Invalid metric name(" << *it
<< ") in configuration file: " << path << "." << std::endl;
return;
}
}
}
revision = reader["revision"].GetInt();
outputDir = reader["output-dir"].GetString();
if (outputDir.empty()) {
std::cerr << "[ERROR] Missing output-dir parameter in config file " << path << "." << std::endl;
return;
}
if (outputDir[0] == '.')
outputDir = jsonPath.parent_path().string() + "/" + outputDir;
if (!exists(outputDir))
boost::filesystem::create_directory(boost::filesystem::path(outputDir));
String covPath = reader["coverage-data"].GetString();
if (covPath[0] == '.') {
covPath = jsonPath.parent_path().string() + "/" + covPath;
}
String resPath = reader["results-data"].GetString();
if (resPath[0] == '.') {
resPath = jsonPath.parent_path().string() + "/" + resPath;
}
if (exists(covPath) && exists(resPath)) {
(std::cerr << "[INFO] loading coverage from " << covPath << " ...").flush();
selectionData->loadCoverage(covPath);
(std::cerr << " done\n[INFO] loading results from " << resPath << " ...").flush();
selectionData->loadResults(resPath);
(std::cerr << " done" << std::endl).flush();
} else {
std::cerr << "[ERROR] Missing or invalid input files in config file " << path << "." << std::endl;
return;
}
if (reader["globalize"].GetBool()) {
(std::cerr << "[INFO] Globalizing ...").flush();
selectionData->globalize();
(std::cerr << " done" << std::endl).flush();
}
clusterList.clear();
metricsCalculated.clear();
(std::cerr << "[INFO] Running cluster algorithm: " << clusterAlgorithm->getName() << " ...").flush();
clusterAlgorithm->execute(*selectionData, clusterList);
(std::cerr << " done" << std::endl).flush();
rapidjson::Document results;
results.SetObject();
for (StringVector::iterator it = metrics.begin(); it != metrics.end(); it++) {
if (metricsCalculated.find(*it) == metricsCalculated.end()) {
calculateMetric(selectionData, *it, results);
}
}
saveResults(results);
delete selectionData;
} catch (std::exception &e) {
std::cerr << e.what() << std::endl;
return;
//.........这里部分代码省略.........