diff options
| author | ras0219 <robertallenschumacher@gmail.com> | 2020-06-26 11:35:41 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-26 11:35:41 -0700 |
| commit | 7ebb42a4d9d8b384bc3128dd571ec9bba8cdd599 (patch) | |
| tree | 0d0fffe5f955d0c8518fed87f0c060942f82c7dc | |
| parent | 4c527e49c44a708ba70026ad4b05601c72558009 (diff) | |
| download | vcpkg-7ebb42a4d9d8b384bc3128dd571ec9bba8cdd599.tar.gz vcpkg-7ebb42a4d9d8b384bc3128dd571ec9bba8cdd599.zip | |
[vcpkg] Fix "[commands-build] build smoke test" (#12128)
* [vcpkg] Fix "[commands-build] build smoke test"
1. Do not exit with a success code in Build::perform, because this causes failures in other tests to be ignored.
2. Use temp directory to avoid interference with the current set of {installed, buildtrees, packages}
3. Explicitly disable binary caching
* [vcpkg] Disable binarycaching in "build smoke test", "[commands-build]"
Return 1 for the last failure case in Build::perform() so testing may continue.
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
| -rw-r--r-- | toolsrc/src/vcpkg-test/commands.build.cpp | 14 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg-test/util.cpp | 7 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/build.cpp | 4 |
3 files changed, 20 insertions, 5 deletions
diff --git a/toolsrc/src/vcpkg-test/commands.build.cpp b/toolsrc/src/vcpkg-test/commands.build.cpp index b1953f55e..bc0dc5b4e 100644 --- a/toolsrc/src/vcpkg-test/commands.build.cpp +++ b/toolsrc/src/vcpkg-test/commands.build.cpp @@ -6,15 +6,27 @@ #include <vcpkg/commands.h> #include <vcpkg/vcpkgcmdarguments.h> #include <vcpkg/vcpkgpaths.h> +#include <vcpkg-test/util.h> + +using namespace vcpkg; TEST_CASE ("build smoke test", "[commands-build]") { - using namespace vcpkg; static const std::string args_raw[] = {"build", "zlib"}; auto& fs_wrapper = Files::get_real_filesystem(); VcpkgCmdArguments args = VcpkgCmdArguments::create_from_arg_sequence(std::begin(args_raw), std::end(args_raw)); + args.binary_caching = false; + args.buildtrees_root_dir = + std::make_unique<std::string>((Test::base_temporary_directory() / fs::u8path("buildtrees")).u8string()); + args.install_root_dir = + std::make_unique<std::string>((Test::base_temporary_directory() / fs::u8path("installed")).u8string()); + args.packages_root_dir = + std::make_unique<std::string>((Test::base_temporary_directory() / fs::u8path("packages")).u8string()); VcpkgPaths paths(fs_wrapper, args); + if (fs_wrapper.exists(paths.buildtrees)) fs_wrapper.remove_all_inside(paths.buildtrees, VCPKG_LINE_INFO); + if (fs_wrapper.exists(paths.packages)) fs_wrapper.remove_all_inside(paths.packages, VCPKG_LINE_INFO); + if (fs_wrapper.exists(paths.installed)) fs_wrapper.remove_all_inside(paths.installed, VCPKG_LINE_INFO); auto triplet = default_triplet(args); const auto exit_code = Build::Command::perform(args, paths, triplet); REQUIRE(exit_code == 0); diff --git a/toolsrc/src/vcpkg-test/util.cpp b/toolsrc/src/vcpkg-test/util.cpp index ce38e62e4..c0b898145 100644 --- a/toolsrc/src/vcpkg-test/util.cpp +++ b/toolsrc/src/vcpkg-test/util.cpp @@ -155,9 +155,12 @@ namespace vcpkg::Test #endif } - const static fs::path BASE_TEMPORARY_DIRECTORY = internal_base_temporary_directory(); - const fs::path& base_temporary_directory() noexcept { return BASE_TEMPORARY_DIRECTORY; } + const fs::path& base_temporary_directory() noexcept + { + const static fs::path BASE_TEMPORARY_DIRECTORY = internal_base_temporary_directory(); + return BASE_TEMPORARY_DIRECTORY; + } #if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_NONE constexpr char no_filesystem_message[] = diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 575fc664c..3f7d3e250 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -140,10 +140,10 @@ namespace vcpkg::Build {
System::print2(System::Color::error, Build::create_error_message(result.code, spec), '\n');
System::print2(Build::create_user_troubleshooting_message(spec), '\n');
- Checks::exit_fail(VCPKG_LINE_INFO);
+ return 1;
}
- Checks::exit_success(VCPKG_LINE_INFO);
+ return 0;
}
int Command::perform(const VcpkgCmdArguments& args, const VcpkgPaths& paths, Triplet default_triplet)
|
