mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +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 "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'
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
32
src/test.cc
32
src/test.cc
@ -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,28 +227,33 @@ 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;
|
||||||
std::cout
|
if (enable_update) {
|
||||||
|
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';
|
||||||
if (!update_all) {
|
if (!update_all) {
|
||||||
c = (char)std::cin.get();
|
c = (char)std::cin.get();
|
||||||
std::cin.get();
|
std::cin.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == 'a')
|
if (c == 'a')
|
||||||
update_all = true;
|
update_all = true;
|
||||||
|
|
||||||
if (update_all || c == 'u') {
|
if (update_all || c == 'u') {
|
||||||
// Note: we use |entry.second| instead of |expected_output| because
|
// Note: we use |entry.second| instead of |expected_output| because
|
||||||
// |expected_output| has had text replacements applied.
|
// |expected_output| has had text replacements applied.
|
||||||
UpdateTestExpectation(path, entry.second, ToString(actual) + "\n");
|
UpdateTestExpectation(path, entry.second, ToString(actual) + "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: ctor/dtor, copy ctor
|
// TODO: ctor/dtor, copy ctor
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user