Fix --keep-going to exit with nonzero if a failure occurred (#670)
* Fix --keep-going to exit with nonzero if a failure occurred * PR comments
This commit is contained in:
Родитель
47c9449a34
Коммит
e4f0750dd5
|
@ -0,0 +1,9 @@
|
|||
. $PSScriptRoot/../end-to-end-tests-prelude.ps1
|
||||
|
||||
# Test keep-going to not report an error
|
||||
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-empty-port", "--keep-going"))
|
||||
Throw-IfFailed
|
||||
|
||||
# Test keep-going to report an error
|
||||
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-fail-if-depended-upon", "--keep-going"))
|
||||
Throw-IfNotFailed
|
|
@ -48,6 +48,7 @@ namespace vcpkg
|
|||
|
||||
void print() const;
|
||||
std::string xunit_results() const;
|
||||
bool failed() const;
|
||||
};
|
||||
|
||||
struct InstallDir
|
||||
|
|
|
@ -431,6 +431,18 @@ namespace vcpkg
|
|||
}
|
||||
}
|
||||
|
||||
bool InstallSummary::failed() const
|
||||
{
|
||||
for (const auto& result : this->results)
|
||||
{
|
||||
if (result.build_result.value_or_exit(VCPKG_LINE_INFO).code != BuildResult::SUCCEEDED)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct TrackedPackageInstallGuard
|
||||
{
|
||||
SpecSummary* current_summary = nullptr;
|
||||
|
@ -1209,13 +1221,14 @@ namespace vcpkg
|
|||
{
|
||||
if (!result.is_user_requested_install()) continue;
|
||||
auto bpgh = result.get_binary_paragraph();
|
||||
assert(bpgh);
|
||||
// If a package failed to build, don't attempt to print usage.
|
||||
// e.g. --keep-going
|
||||
if (!bpgh) continue;
|
||||
Install::print_usage_information(*bpgh, printed_usages, fs, paths.installed());
|
||||
}
|
||||
}
|
||||
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
Checks::exit_with_code(VCPKG_LINE_INFO, summary.failed());
|
||||
}
|
||||
|
||||
void InstallCommand::perform_and_exit(const VcpkgCmdArguments& args,
|
||||
|
|
Загрузка…
Ссылка в новой задаче