aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test
diff options
context:
space:
mode:
authorBilly O'Neal <bion@microsoft.com>2020-05-14 12:49:31 -0700
committerGitHub <noreply@github.com>2020-05-14 12:49:31 -0700
commit5504dfa7da38a65981868fc7885744ac5d8f234e (patch)
tree1d95de86ef1604d2393a05d5be16437d36fe6822 /toolsrc/src/vcpkg-test
parent4727bc86a4d6fa2c009ae9932eef3a668a358e60 (diff)
downloadvcpkg-5504dfa7da38a65981868fc7885744ac5d8f234e.tar.gz
vcpkg-5504dfa7da38a65981868fc7885744ac5d8f234e.zip
[vcpkg] Turn on tests and PREfast in CI, and fix tests to pass. (#11239)
Co-authored-by: nicole mazzuca <mazzucan@outlook.com>
Diffstat (limited to 'toolsrc/src/vcpkg-test')
-rw-r--r--toolsrc/src/vcpkg-test/plan.cpp5
-rw-r--r--toolsrc/src/vcpkg-test/system.cpp18
-rw-r--r--toolsrc/src/vcpkg-test/util.cpp2
3 files changed, 10 insertions, 15 deletions
diff --git a/toolsrc/src/vcpkg-test/plan.cpp b/toolsrc/src/vcpkg-test/plan.cpp
index 75e8acd58..a39c2b4a4 100644
--- a/toolsrc/src/vcpkg-test/plan.cpp
+++ b/toolsrc/src/vcpkg-test/plan.cpp
@@ -369,9 +369,8 @@ TEST_CASE ("basic feature test 7", "[plan]")
remove_plan_check(plan.remove_actions.at(0), "x");
remove_plan_check(plan.remove_actions.at(1), "b");
- // TODO: order here may change but A < X, and B anywhere
- features_check(plan.install_actions.at(0), "b", {"core", "b1"});
- features_check(plan.install_actions.at(1), "a", {"core"});
+ features_check(plan.install_actions.at(0), "a", {"core"});
+ features_check(plan.install_actions.at(1), "b", {"core", "b1"});
features_check(plan.install_actions.at(2), "x", {"core"});
}
diff --git a/toolsrc/src/vcpkg-test/system.cpp b/toolsrc/src/vcpkg-test/system.cpp
index 70424f0b5..6b9dfaf95 100644
--- a/toolsrc/src/vcpkg-test/system.cpp
+++ b/toolsrc/src/vcpkg-test/system.cpp
@@ -1,3 +1,4 @@
+#define _POSIX_C_SOURCE 200112L
#include <catch2/catch.hpp>
#include <string>
@@ -27,7 +28,7 @@ using vcpkg::System::CPUArchitecture;
namespace
{
- void set_environment_variable(StringView varname, Optional<std::string> value)
+ void set_environment_variable(ZStringView varname, Optional<std::string> value)
{
#if defined(_WIN32)
const auto w_varname = vcpkg::Strings::to_utf16(varname);
@@ -45,19 +46,14 @@ namespace
check_exit(VCPKG_LINE_INFO, exit_code != 0);
#else // ^^^ defined(_WIN32) / !defined(_WIN32) vvv
- std::string tmp;
- tmp.append(varname.data(), varname.size());
- tmp.push_back('=');
if (auto v = value.get())
{
- tmp.append(*v);
+ check_exit(VCPKG_LINE_INFO, setenv(varname.c_str(), v->c_str(), 1) == 0);
+ }
+ else
+ {
+ check_exit(VCPKG_LINE_INFO, unsetenv(varname.c_str()) == 0);
}
-
- // putenv expects the string to never go out of scope
- char* env_string = new char[tmp.size() + 1]; // overflow checked by tmp's null allocation
- memcpy(env_string, tmp.data(), tmp.size());
- const int exit_code = putenv(env_string);
- check_exit(VCPKG_LINE_INFO, exit_code == 0);
#endif // defined(_WIN32)
}
diff --git a/toolsrc/src/vcpkg-test/util.cpp b/toolsrc/src/vcpkg-test/util.cpp
index c615f6bb2..8ead355f1 100644
--- a/toolsrc/src/vcpkg-test/util.cpp
+++ b/toolsrc/src/vcpkg-test/util.cpp
@@ -126,7 +126,7 @@ namespace vcpkg::Test
if (status == ERROR_SUCCESS && data == 1) {
return AllowSymlinks::Yes;
} else {
- std::clog << "Symlinks are not allowed on this system\n";
+ std::cout << "Symlinks are not allowed on this system\n";
return AllowSymlinks::No;
}
#endif