aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test/system.cpp
diff options
context:
space:
mode:
authorras0219 <robertallenschumacher@gmail.com>2020-06-26 12:16:02 -0700
committerGitHub <noreply@github.com>2020-06-26 12:16:02 -0700
commit91e798afd899f84654f25e3d7f5beb276c6bd5af (patch)
treefcc620a5c63d3523c03c9c30c56188b13276b5a5 /toolsrc/src/vcpkg-test/system.cpp
parent7ebb42a4d9d8b384bc3128dd571ec9bba8cdd599 (diff)
downloadvcpkg-91e798afd899f84654f25e3d7f5beb276c6bd5af.tar.gz
vcpkg-91e798afd899f84654f25e3d7f5beb276c6bd5af.zip
[vcpkg] Implementation of --x-binarysource=nuget (and friends) (#12058)
* [vcpkg] Initial implementation of --x-binarysource=nuget * [vcpkg] Remove double-double quoting of CMake arguments * [vcpkg] Update nuget.exe to 5.5.1 to support Azure DevOps Artifacts * [vcpkg] Enable batching of NuGet server calls with prefetch(). Add `interactive` binarysource. * [vcpkg] Add `nugetconfig` binary source * [vcpkg] Short circuit querying remote NuGet servers once all refs are found * [vcpkg] Add experimental help for binary caching * [vcpkg] Improved NuGet cache package descriptions and version formatting * [vcpkg] Rename `CmdLineBuilder::build()` to extract() * [vcpkg-help] Ascii-betize help topics * [vcpkg] Add tests for cmdlinebuilder. Improve handling of quotes and slashes. * [vcpkg] Addressing code review comments * [vcpkg] Add tests for vcpkg::reformat_version() * [vcpkg] Added test for vcpkg::generate_nuspec() * [vcpkg] Add tests for vcpkg::XmlSerializer * [vcpkg] Addressed code review comment * [vcpkg] Add test for vcpkg::Strings::find_first_of * [vcpkg] Fix machine-specific paths in test for vcpkg::generate_nuspec() Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc/src/vcpkg-test/system.cpp')
-rw-r--r--toolsrc/src/vcpkg-test/system.cpp52
1 files changed, 33 insertions, 19 deletions
diff --git a/toolsrc/src/vcpkg-test/system.cpp b/toolsrc/src/vcpkg-test/system.cpp
index 6e87f9b3e..8b44f8f24 100644
--- a/toolsrc/src/vcpkg-test/system.cpp
+++ b/toolsrc/src/vcpkg-test/system.cpp
@@ -7,16 +7,17 @@
#include <vcpkg/base/zstringview.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.h>
+#include <vcpkg/base/system.process.h>
+using vcpkg::nullopt;
using vcpkg::Optional;
using vcpkg::StringView;
using vcpkg::ZStringView;
using vcpkg::Checks::check_exit;
+using vcpkg::System::CPUArchitecture;
using vcpkg::System::get_environment_variable;
-using vcpkg::System::to_cpu_architecture;
using vcpkg::System::guess_visual_studio_prompt_target_architecture;
-using vcpkg::nullopt;
-using vcpkg::System::CPUArchitecture;
+using vcpkg::System::to_cpu_architecture;
namespace
{
@@ -126,30 +127,43 @@ TEST_CASE ("guess_visual_studio_prompt", "[system]")
set_environment_variable("VSCMD_ARG_TGT_ARCH", nullopt);
CHECK(!guess_visual_studio_prompt_target_architecture().has_value());
set_environment_variable("VSCMD_ARG_TGT_ARCH", "x86");
- CHECK(guess_visual_studio_prompt_target_architecture()
- .value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X86);
+ CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X86);
set_environment_variable("VSCMD_ARG_TGT_ARCH", "x64");
- CHECK(guess_visual_studio_prompt_target_architecture()
- .value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X64);
+ CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X64);
set_environment_variable("VSCMD_ARG_TGT_ARCH", "arm");
- CHECK(guess_visual_studio_prompt_target_architecture()
- .value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::ARM);
+ CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::ARM);
set_environment_variable("VSCMD_ARG_TGT_ARCH", "arm64");
- CHECK(guess_visual_studio_prompt_target_architecture()
- .value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::ARM64);
+ CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::ARM64);
// check that apparent "nested" prompts defer to "vsdevcmd"
set_environment_variable("VCINSTALLDIR", "anything");
- CHECK(guess_visual_studio_prompt_target_architecture()
- .value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::ARM64);
+ CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::ARM64);
set_environment_variable("VSCMD_ARG_TGT_ARCH", nullopt);
set_environment_variable("Platform", nullopt);
- CHECK(guess_visual_studio_prompt_target_architecture()
- .value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X86);
+ CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X86);
set_environment_variable("Platform", "x86");
- CHECK(guess_visual_studio_prompt_target_architecture()
- .value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X86);
+ CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X86);
set_environment_variable("Platform", "x64");
- CHECK(guess_visual_studio_prompt_target_architecture()
- .value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X64);
+ CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X64);
+}
+
+TEST_CASE ("cmdlinebuilder", "[system]")
+{
+ using vcpkg::System::CmdLineBuilder;
+
+ CmdLineBuilder cmd;
+ cmd.path_arg(fs::u8path("relative/path.exe"));
+ cmd.string_arg("abc");
+ cmd.string_arg("hello world!");
+ cmd.string_arg("|");
+ cmd.string_arg(";");
+ REQUIRE(cmd.extract() == "relative/path.exe abc \"hello world!\" \"|\" \";\"");
+
+ cmd.path_arg(fs::u8path("trailing\\slash\\"));
+ cmd.string_arg("inner\"quotes");
+#ifdef _WIN32
+ REQUIRE(cmd.extract() == "\"trailing\\slash\\\\\" \"inner\\\"quotes\"");
+#else
+ REQUIRE(cmd.extract() == "\"trailing\\\\slash\\\\\" \"inner\\\"quotes\"");
+#endif
}