[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:
Jacob Dufault 2018-01-03 18:43:45 -08:00
parent cd3faf4dfe
commit 0c839d19fc
5 changed files with 29 additions and 19 deletions

View File

@ -19,8 +19,8 @@ build_script:
copy "build\release\bin\*" "${dir}\build\release\bin" 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\" 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}" 7z a -tzip "C:\projects\cquery\${dir}.zip" "${dir}"
- build\release\bin\cquery --log-all-to-stderr --test-unit - build\release\bin\cquery --ci --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-index
artifacts: artifacts:
- path: 'cquery-*.zip' - path: 'cquery-*.zip'

View File

@ -195,8 +195,8 @@ before_script:
script: script:
- travis_retry ./waf configure - travis_retry ./waf configure
- ./waf build - ./waf build
- ./build/release/bin/cquery --log-all-to-stderr --test-unit - ./build/release/bin/cquery --ci --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-index
notifications: notifications:
email: false email: false

View File

@ -430,7 +430,8 @@ int main(int argc, char** argv) {
if (HasOption(options, "--test-index")) { if (HasOption(options, "--test-index")) {
print_help = false; print_help = false;
RunIndexTests(options["--test-index"]); if (!RunIndexTests(options["--test-index"], !HasOption(options, "--ci")))
return -1;
} }
if (HasOption(options, "--enable-comments")) { if (HasOption(options, "--enable-comments")) {
@ -483,6 +484,9 @@ Command line options:
If true, cquery will wait for an '[Enter]' before exiting. If true, cquery will wait for an '[Enter]' before exiting.
Useful on windows. Useful on windows.
--help Print this help information. --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: Configuration:
When opening up a directory, cquery will look for a compile_commands.json file When opening up a directory, cquery will look for a compile_commands.json file

View File

@ -108,7 +108,7 @@ IndexFile* FindDbForPathEnding(
return nullptr; return nullptr;
} }
void RunIndexTests(const std::string& filter_path) { bool RunIndexTests(const std::string& filter_path, bool enable_update) {
SetTestOutputMode(); SetTestOutputMode();
// Index tests change based on the version of clang used. // Index tests change based on the version of clang used.
@ -121,6 +121,7 @@ void RunIndexTests(const std::string& filter_path) {
exit(1); exit(1);
} }
bool success = true;
bool update_all = false; bool update_all = false;
ClangIndex index; ClangIndex index;
@ -226,9 +227,11 @@ void RunIndexTests(const std::string& filter_path) {
if (actual == expected) { if (actual == expected) {
// std::cout << "[PASSED] " << path << std::endl; // std::cout << "[PASSED] " << path << std::endl;
} else { } else {
success = false;
DiffDocuments(path, expected_path, expected, actual); DiffDocuments(path, expected_path, expected, actual);
std::cout << std::endl; std::cout << std::endl;
std::cout << std::endl; std::cout << std::endl;
if (enable_update) {
std::cout std::cout
<< "[Enter to continue - type u to update test, a to update all]"; << "[Enter to continue - type u to update test, a to update all]";
char c = 'u'; char c = 'u';
@ -248,6 +251,9 @@ void RunIndexTests(const std::string& filter_path) {
} }
} }
} }
}
return success;
} }
// TODO: ctor/dtor, copy ctor // TODO: ctor/dtor, copy ctor

View File

@ -2,4 +2,4 @@
#include <string> #include <string>
void RunIndexTests(const std::string& filter_path); bool RunIndexTests(const std::string& filter_path, bool enable_update);