mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-21 23:25:07 +00:00
[ci]: Do not wait for input after failing a test.
This adds --ci command line flag which disables waiting for user input when running an index test (ie, test expectations are not updated).
This commit is contained in:
parent
cd3faf4dfe
commit
0c839d19fc
@ -19,8 +19,8 @@ build_script:
|
||||
copy "build\release\bin\*" "${dir}\build\release\bin"
|
||||
copy -recurse "build\LLVM-5.0.1-win64\lib\clang\5.0.1\include" "${dir}\build\release\lib\LLVM-5.0.1-win64\lib\clang\5.0.1\"
|
||||
7z a -tzip "C:\projects\cquery\${dir}.zip" "${dir}"
|
||||
- build\release\bin\cquery --log-all-to-stderr --test-unit
|
||||
- build\release\bin\cquery --log-all-to-stderr --test-index
|
||||
- build\release\bin\cquery --ci --log-all-to-stderr --test-unit
|
||||
- build\release\bin\cquery --ci --log-all-to-stderr --test-index
|
||||
|
||||
artifacts:
|
||||
- path: 'cquery-*.zip'
|
||||
|
@ -195,8 +195,8 @@ before_script:
|
||||
script:
|
||||
- travis_retry ./waf configure
|
||||
- ./waf build
|
||||
- ./build/release/bin/cquery --log-all-to-stderr --test-unit
|
||||
- ./build/release/bin/cquery --log-all-to-stderr --test-index
|
||||
- ./build/release/bin/cquery --ci --log-all-to-stderr --test-unit
|
||||
- ./build/release/bin/cquery --ci --log-all-to-stderr --test-index
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
@ -430,7 +430,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
if (HasOption(options, "--test-index")) {
|
||||
print_help = false;
|
||||
RunIndexTests(options["--test-index"]);
|
||||
if (!RunIndexTests(options["--test-index"], !HasOption(options, "--ci")))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (HasOption(options, "--enable-comments")) {
|
||||
@ -483,6 +484,9 @@ Command line options:
|
||||
If true, cquery will wait for an '[Enter]' before exiting.
|
||||
Useful on windows.
|
||||
--help Print this help information.
|
||||
--ci Prevents tests from prompting the user for input. Used for
|
||||
continuous integration so it can fail faster instead of timing
|
||||
out.
|
||||
|
||||
Configuration:
|
||||
When opening up a directory, cquery will look for a compile_commands.json file
|
||||
|
32
src/test.cc
32
src/test.cc
@ -108,7 +108,7 @@ IndexFile* FindDbForPathEnding(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void RunIndexTests(const std::string& filter_path) {
|
||||
bool RunIndexTests(const std::string& filter_path, bool enable_update) {
|
||||
SetTestOutputMode();
|
||||
|
||||
// Index tests change based on the version of clang used.
|
||||
@ -121,6 +121,7 @@ void RunIndexTests(const std::string& filter_path) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bool success = true;
|
||||
bool update_all = false;
|
||||
ClangIndex index;
|
||||
|
||||
@ -226,28 +227,33 @@ void RunIndexTests(const std::string& filter_path) {
|
||||
if (actual == expected) {
|
||||
// std::cout << "[PASSED] " << path << std::endl;
|
||||
} else {
|
||||
success = false;
|
||||
DiffDocuments(path, expected_path, expected, actual);
|
||||
std::cout << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout
|
||||
if (enable_update) {
|
||||
std::cout
|
||||
<< "[Enter to continue - type u to update test, a to update all]";
|
||||
char c = 'u';
|
||||
if (!update_all) {
|
||||
c = (char)std::cin.get();
|
||||
std::cin.get();
|
||||
}
|
||||
char c = 'u';
|
||||
if (!update_all) {
|
||||
c = (char)std::cin.get();
|
||||
std::cin.get();
|
||||
}
|
||||
|
||||
if (c == 'a')
|
||||
update_all = true;
|
||||
if (c == 'a')
|
||||
update_all = true;
|
||||
|
||||
if (update_all || c == 'u') {
|
||||
// Note: we use |entry.second| instead of |expected_output| because
|
||||
// |expected_output| has had text replacements applied.
|
||||
UpdateTestExpectation(path, entry.second, ToString(actual) + "\n");
|
||||
if (update_all || c == 'u') {
|
||||
// Note: we use |entry.second| instead of |expected_output| because
|
||||
// |expected_output| has had text replacements applied.
|
||||
UpdateTestExpectation(path, entry.second, ToString(actual) + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// TODO: ctor/dtor, copy ctor
|
||||
|
@ -2,4 +2,4 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
void RunIndexTests(const std::string& filter_path);
|
||||
bool RunIndexTests(const std::string& filter_path, bool enable_update);
|
||||
|
Loading…
Reference in New Issue
Block a user