aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test
diff options
context:
space:
mode:
authorras0219 <533828+ras0219@users.noreply.github.com>2021-02-02 15:00:33 -0800
committerGitHub <noreply@github.com>2021-02-02 15:00:33 -0800
commit5793c4bd9f5d3a8e9087d444beba202e753ec4c9 (patch)
treeda656084cd9fd4685d202b8fd24d852ce7185d84 /toolsrc/src/vcpkg-test
parent3b4a4e4b5cff58ae9af6b46ad63fda71146f6ce4 (diff)
downloadvcpkg-5793c4bd9f5d3a8e9087d444beba202e753ec4c9.tar.gz
vcpkg-5793c4bd9f5d3a8e9087d444beba202e753ec4c9.zip
[vcpkg] Miscellaneous internal improvements extracted from #15424 (#15677)
* [vcpkg] Miscellaneous internal improvements extracted from #15424 * [vcpkg] CR comments * [armadillo] Use vcpkg_from_git() to workaround gitlab missing archive Co-authored-by: Robert Schumacher <roschuma@microsoft.com> Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Diffstat (limited to 'toolsrc/src/vcpkg-test')
-rw-r--r--toolsrc/src/vcpkg-test/catch.cpp3
-rw-r--r--toolsrc/src/vcpkg-test/commands.build.cpp38
-rw-r--r--toolsrc/src/vcpkg-test/manifests.cpp14
-rw-r--r--toolsrc/src/vcpkg-test/optional.cpp27
4 files changed, 40 insertions, 42 deletions
diff --git a/toolsrc/src/vcpkg-test/catch.cpp b/toolsrc/src/vcpkg-test/catch.cpp
index 50331c644..fb62c5d06 100644
--- a/toolsrc/src/vcpkg-test/catch.cpp
+++ b/toolsrc/src/vcpkg-test/catch.cpp
@@ -2,10 +2,11 @@
#include <catch2/catch.hpp>
#include <vcpkg/base/system.debug.h>
+#include <vcpkg/base/system.h>
int main(int argc, char** argv)
{
- vcpkg::Debug::g_debugging = true;
+ if (vcpkg::System::get_environment_variable("VCPKG_DEBUG").value_or("") == "1") vcpkg::Debug::g_debugging = true;
return Catch::Session().run(argc, argv);
}
diff --git a/toolsrc/src/vcpkg-test/commands.build.cpp b/toolsrc/src/vcpkg-test/commands.build.cpp
deleted file mode 100644
index 467fadd72..000000000
--- a/toolsrc/src/vcpkg-test/commands.build.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/files.h>
-
-#include <vcpkg/build.h>
-#include <vcpkg/commands.h>
-#include <vcpkg/vcpkgcmdarguments.h>
-#include <vcpkg/vcpkgpaths.h>
-
-#include <iterator>
-#include <string>
-
-#include <vcpkg-test/util.h>
-
-using namespace vcpkg;
-
-TEST_CASE ("build smoke test", "[commands-build]")
-{
- 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>(fs::u8string(Test::base_temporary_directory() / fs::u8path("buildtrees")));
- args.install_root_dir =
- std::make_unique<std::string>(fs::u8string(Test::base_temporary_directory() / fs::u8path("installed")));
- args.packages_root_dir =
- std::make_unique<std::string>(fs::u8string(Test::base_temporary_directory() / fs::u8path("packages")));
- 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);
- REQUIRE(paths.get_filesystem().is_directory(paths.buildtrees / fs::u8path("zlib")));
-}
diff --git a/toolsrc/src/vcpkg-test/manifests.cpp b/toolsrc/src/vcpkg-test/manifests.cpp
index 0af9f4f96..7cf92818e 100644
--- a/toolsrc/src/vcpkg-test/manifests.cpp
+++ b/toolsrc/src/vcpkg-test/manifests.cpp
@@ -691,13 +691,21 @@ TEST_CASE ("Serialize all the ports", "[manifests]")
const auto manifest = dir / fs::u8path("vcpkg.json");
if (fs.exists(control))
{
+ INFO(fs::u8string(control));
auto contents = fs.read_contents(control, VCPKG_LINE_INFO);
auto pghs = Paragraphs::parse_paragraphs(contents, fs::u8string(control));
REQUIRE(pghs);
- scfs.push_back(std::move(*SourceControlFile::parse_control_file(
- fs::u8string(control), std::move(pghs).value_or_exit(VCPKG_LINE_INFO))
- .value_or_exit(VCPKG_LINE_INFO)));
+ auto scf = SourceControlFile::parse_control_file(fs::u8string(control),
+ std::move(pghs).value_or_exit(VCPKG_LINE_INFO));
+ if (!scf)
+ {
+ INFO(scf.error()->name);
+ INFO(scf.error()->error);
+ REQUIRE(scf);
+ }
+
+ scfs.push_back(std::move(*scf.value_or_exit(VCPKG_LINE_INFO)));
}
else if (fs.exists(manifest))
{
diff --git a/toolsrc/src/vcpkg-test/optional.cpp b/toolsrc/src/vcpkg-test/optional.cpp
index c2656d97e..f18efb359 100644
--- a/toolsrc/src/vcpkg-test/optional.cpp
+++ b/toolsrc/src/vcpkg-test/optional.cpp
@@ -80,6 +80,33 @@ TEST_CASE ("value conversion", "[optional]")
REQUIRE(o_v.get()->size() == 3);
}
+TEST_CASE ("optional.map", "[optional]")
+{
+ using vcpkg::NullOpt;
+ using vcpkg::nullopt;
+ using vcpkg::Optional;
+
+ const Optional<std::unique_ptr<int>> move_only;
+
+ Optional<int*> m = move_only.map([](auto&& p) { return p.get(); });
+ Optional<Optional<int*>> n =
+ move_only.map([](auto&& p) -> Optional<int*> { return p ? Optional<int*>{p.get()} : nullopt; });
+ Optional<NullOpt> o = move_only.map([](auto&&) { return nullopt; });
+
+ Optional<int> five = 5;
+
+ struct MoveTest
+ {
+ int operator()(int&&) { return 1; }
+ int operator()(const int&) { return -1; }
+ } move_test;
+
+ Optional<int> dst = std::move(five).map(move_test);
+ REQUIRE(dst == 1);
+ Optional<int> dst2 = five.map(move_test);
+ REQUIRE(dst2 == -1);
+}
+
TEST_CASE ("common_projection", "[optional]")
{
using vcpkg::Util::common_projection;