mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
@@ -5,6 +5,7 @@
|
||||
#include <tree_sitter/api.h>
|
||||
#include <tree_sitter/parser.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
@@ -35,7 +36,9 @@ auto main(int argc, char** argv) -> int {
|
||||
auto* parser = ts_parser_new();
|
||||
ts_parser_set_language(parser, tree_sitter_carbon());
|
||||
|
||||
std::vector<std::string> failed;
|
||||
bool fail_tests = std::getenv("FAIL_TESTS") != nullptr;
|
||||
|
||||
std::vector<std::string> incorrect;
|
||||
for (int i = 1; i < argc; i++) {
|
||||
std::string file_path = argv[i];
|
||||
std::string source = ReadFile(file_path);
|
||||
@@ -48,19 +51,27 @@ auto main(int argc, char** argv) -> int {
|
||||
char* node_debug = ts_node_string(root);
|
||||
|
||||
std::cout << file_path << ":\n" << node_debug << "\n";
|
||||
if (has_error) {
|
||||
failed.push_back(file_path);
|
||||
if (has_error ^ fail_tests) {
|
||||
incorrect.push_back(file_path);
|
||||
}
|
||||
|
||||
free(node_debug);
|
||||
ts_tree_delete(tree);
|
||||
}
|
||||
ts_parser_delete(parser);
|
||||
for (const auto& file : failed) {
|
||||
std::cout << "FAILED " << file << "\n";
|
||||
for (const auto& file : incorrect) {
|
||||
if (fail_tests) {
|
||||
std::cout << "INCORRECTLY PASSING " << file << "\n";
|
||||
} else {
|
||||
std::cout << "FAILED " << file << "\n";
|
||||
}
|
||||
}
|
||||
if (!failed.empty()) {
|
||||
std::cout << failed.size() << " tests failing.\n";
|
||||
if (!incorrect.empty()) {
|
||||
if (fail_tests) {
|
||||
std::cout << incorrect.size() << " tests incorrectly passing.\n";
|
||||
} else {
|
||||
std::cout << incorrect.size() << " tests failing.\n";
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user