diff options
| author | Curtis J Bezault <curtbezault@gmail.com> | 2019-08-09 11:59:32 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-09 11:59:32 -0400 |
| commit | c4f1a91ef245ed3e44ea11f13040a77453126165 (patch) | |
| tree | 3e6c99d970fe8a5fcd1551bbcbf9fde4f0b0a3a4 /toolsrc/include/vcpkg-test | |
| parent | 9da7c5c99ee42e382895dbd0dafdd29beaa61075 (diff) | |
| parent | 743e168ef5c7705e44d1d5cab5b9cca22328345e (diff) | |
| download | vcpkg-c4f1a91ef245ed3e44ea11f13040a77453126165.tar.gz vcpkg-c4f1a91ef245ed3e44ea11f13040a77453126165.zip | |
Merge branch 'master' into external_file_abi
Diffstat (limited to 'toolsrc/include/vcpkg-test')
| -rw-r--r-- | toolsrc/include/vcpkg-test/util.h | 78 |
1 files changed, 52 insertions, 26 deletions
diff --git a/toolsrc/include/vcpkg-test/util.h b/toolsrc/include/vcpkg-test/util.h index fa650abc8..8a458a3e5 100644 --- a/toolsrc/include/vcpkg-test/util.h +++ b/toolsrc/include/vcpkg-test/util.h @@ -1,42 +1,68 @@ +#include <vcpkg-test/catch.h> +#include <vcpkg/pragmas.h> + #include <vcpkg/base/files.h> #include <vcpkg/statusparagraph.h> #include <memory> -namespace vcpkg::Test { +#define CHECK_EC(ec) \ + do \ + { \ + if (ec) \ + { \ + FAIL(ec.message()); \ + } \ + } while (0) -std::unique_ptr<vcpkg::StatusParagraph> make_status_pgh(const char* name, - const char* depends = "", - const char* default_features = "", - const char* triplet = "x86-windows"); +namespace vcpkg::Test +{ + std::unique_ptr<vcpkg::StatusParagraph> make_status_pgh(const char* name, + const char* depends = "", + const char* default_features = "", + const char* triplet = "x86-windows"); -std::unique_ptr<vcpkg::StatusParagraph> make_status_feature_pgh(const char* name, - const char* feature, - const char* depends = "", - const char* triplet = "x86-windows"); + std::unique_ptr<vcpkg::StatusParagraph> make_status_feature_pgh(const char* name, + const char* feature, + const char* depends = "", + const char* triplet = "x86-windows"); -vcpkg::PackageSpec unsafe_pspec(std::string name, vcpkg::Triplet t = vcpkg::Triplet::X86_WINDOWS); + vcpkg::PackageSpec unsafe_pspec(std::string name, vcpkg::Triplet t = vcpkg::Triplet::X86_WINDOWS); -template<class T, class S> -T&& unwrap(vcpkg::ExpectedT<T, S>&& p) -{ - REQUIRE(p.has_value()); - return std::move(*p.get()); -} + template<class T, class S> + T&& unwrap(vcpkg::ExpectedT<T, S>&& p) + { + REQUIRE(p.has_value()); + return std::move(*p.get()); + } -template<class T> -T&& unwrap(vcpkg::Optional<T>&& opt) -{ - REQUIRE(opt.has_value()); - return std::move(*opt.get()); -} + template<class T> + T&& unwrap(vcpkg::Optional<T>&& opt) + { + REQUIRE(opt.has_value()); + return std::move(*opt.get()); + } + + struct AllowSymlinks + { + enum Tag : bool + { + No = false, + Yes = true, + } tag; + + constexpr AllowSymlinks(Tag tag) noexcept : tag(tag) {} + + constexpr explicit AllowSymlinks(bool b) noexcept : tag(b ? Yes : No) {} -extern const bool SYMLINKS_ALLOWED; + constexpr operator bool() const noexcept { return tag == Yes; } + }; -extern const fs::path TEMPORARY_DIRECTORY; + AllowSymlinks can_create_symlinks() noexcept; -void create_symlink(const fs::path& file, const fs::path& target, std::error_code& ec); + const fs::path& base_temporary_directory() noexcept; -void create_directory_symlink(const fs::path& file, const fs::path& target, std::error_code& ec); + void create_symlink(const fs::path& file, const fs::path& target, std::error_code& ec); + void create_directory_symlink(const fs::path& file, const fs::path& target, std::error_code& ec); } |
