Skip to content

Commit

Permalink
Don't emit the triplet warning with x-set-installed no args. (#1006)
Browse files Browse the repository at this point in the history
* Don't emit the triplet warning with x-set-installed no args.

Also added e2e tests.

* clang-format

* Add purpose specific unit tests, including a new test for platform qualified expressions.

* Add end to end test for the environment variable being set not emitting the warning.
  • Loading branch information
BillyONeal authored Apr 6, 2023
1 parent bbace1f commit 823c16e
Show file tree
Hide file tree
Showing 23 changed files with 457 additions and 136 deletions.
143 changes: 143 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/cli.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,146 @@ Throw-IfNotFailed

Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "--fast")) # --fast is not a switch
Throw-IfNotFailed

if ($IsWindows) {
$warningText = 'Starting with the September 2023 release'

# build-external not tested
# ci not tested
# export not tested

# depend-info
[string]$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('depend-info', 'vcpkg-hello-world-1'))
Throw-IfFailed
if (-Not $output.Contains($warningText)) {
throw 'depend-info with unqualified spec should emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('depend-info', 'vcpkg-hello-world-1:x64-windows'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'depend-info with qualified parameters should not emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('depend-info', 'vcpkg-hello-world-1', '--triplet', 'x86-windows'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'depend-info with arg should not emit the triplet warning'
}

# set-installed
$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('x-set-installed'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'x-set-installed with no parameters should not emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('x-set-installed', 'vcpkg-hello-world-1'))
Throw-IfFailed
if (-Not $output.Contains($warningText)) {
throw 'x-set-installed with unqualified spec should emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('x-set-installed', 'vcpkg-hello-world-1:x64-windows'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'x-set-installed with qualified parameters should not emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('x-set-installed', 'vcpkg-hello-world-1', '--triplet', 'x86-windows'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'x-set-installed with arg should not emit the triplet warning'
}

# install
Refresh-TestRoot
$sub = Join-Path $TestingRoot 'manifest-warn'
New-Item -ItemType Directory -Force $sub | Out-Null
Push-Location $sub
try {
Run-Vcpkg -TestArgs ($directoryArgs + @('new', '--application'))
Throw-IfFailed

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('install'))
Throw-IfFailed
if (-Not $output.Contains($warningText)) {
throw 'manifest install should emit the triplet warning'
}
} finally {
Pop-Location
}

Refresh-TestRoot
$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('install', 'vcpkg-hello-world-1'))
Throw-IfFailed
if (-Not $output.Contains($warningText)) {
throw 'install with unqualified spec should emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('install', 'vcpkg-hello-world-1:x64-windows'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'install with qualified parameters should not emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('install', 'vcpkg-hello-world-1', '--triplet', 'x86-windows'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'install with arg should not emit the triplet warning'
}

# upgrade
$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('upgrade'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'upgrade with no parameters should not emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('upgrade', 'vcpkg-hello-world-1'))
Throw-IfFailed
if (-Not $output.Contains($warningText)) {
throw 'upgrade with unqualified spec should emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('upgrade', 'vcpkg-hello-world-1:x64-windows'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'upgrade with qualified parameters should not emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('upgrade', 'vcpkg-hello-world-1', '--triplet', 'x86-windows'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'upgrade with arg should not emit the triplet warning'
}

# remove
$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('remove', 'vcpkg-hello-world-1'))
Throw-IfFailed
if (-Not $output.Contains($warningText)) {
throw 'remove with unqualified spec should emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('remove', 'vcpkg-hello-world-1:x64-windows'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'remove with qualified parameters should not emit the triplet warning'
}

$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('remove', 'vcpkg-hello-world-1', '--triplet', 'x86-windows'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'remove with arg should not emit the triplet warning'
}

$env:VCPKG_DEFAULT_TRIPLET = 'x86-windows'
Refresh-TestRoot
$output = Run-VcpkgAndCaptureOutput -TestArgs ($directoryArgs + @('install', 'vcpkg-hello-world-1'))
Throw-IfFailed
if ($output.Contains($warningText)) {
throw 'install with environment variable set should not emit the triplet warning'
}

Remove-Item env:VCPKG_DEFAULT_TRIPLET
}
10 changes: 7 additions & 3 deletions azure-pipelines/end-to-end-tests-prelude.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ $NuGetRoot = Join-Path $TestingRoot 'nuget'
$NuGetRoot2 = Join-Path $TestingRoot 'nuget2'
$ArchiveRoot = Join-Path $TestingRoot 'archives'
$VersionFilesRoot = Join-Path $TestingRoot 'version-test'
$commonArgs = @(
"--triplet",
$Triplet,
$directoryArgs = @(
"--x-buildtrees-root=$buildtreesRoot",
"--x-install-root=$installRoot",
"--x-packages-root=$packagesRoot",
"--overlay-ports=$PSScriptRoot/e2e_ports/overlays",
"--overlay-triplets=$PSScriptRoot/e2e_ports/triplets"
)

$commonArgs = @(
"--triplet",
$Triplet
) + $directoryArgs

$Script:CurrentTest = 'unassigned'

function Refresh-TestRoot {
Expand Down
26 changes: 3 additions & 23 deletions include/vcpkg-test/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,8 @@ namespace vcpkg::Test
const std::vector<std::pair<const char*, const char*>>& features = {},
const std::vector<const char*>& default_features = {});

inline auto test_parse_control_file(const std::vector<std::unordered_map<std::string, std::string>>& v)
{
std::vector<vcpkg::Paragraph> pghs;
for (auto&& p : v)
{
pghs.emplace_back();
for (auto&& kv : p)
pghs.back().emplace(kv.first, std::make_pair(kv.second, vcpkg::TextRowCol{}));
}
return vcpkg::SourceControlFile::parse_control_file("", std::move(pghs));
}
ParseExpected<SourceControlFile> test_parse_control_file(
const std::vector<std::unordered_map<std::string, std::string>>& v);

std::unique_ptr<vcpkg::StatusParagraph> make_status_pgh(const char* name,
const char* depends = "",
Expand Down Expand Up @@ -143,18 +134,7 @@ namespace vcpkg::Test
PackageSpec emplace(vcpkg::SourceControlFileAndLocation&& scfl);
};

inline std::vector<FullPackageSpec> parse_test_fspecs(StringView sv, Triplet t = X86_WINDOWS)
{
std::vector<FullPackageSpec> ret;
ParserBase parser(sv, "test");
while (!parser.at_eof())
{
auto opt = parse_qualified_specifier(parser);
REQUIRE(opt.has_value());
ret.push_back(opt.get()->to_full_spec(t, ImplicitDefault::YES).value_or_exit(VCPKG_LINE_INFO));
}
return ret;
}
std::vector<FullPackageSpec> parse_test_fspecs(StringView sv);

template<class R1, class R2>
void check_ranges(const R1& r1, const R2& r2)
Expand Down
4 changes: 3 additions & 1 deletion include/vcpkg/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ namespace vcpkg
{
PackageSpec check_and_get_package_spec(std::string&& spec_string,
Triplet default_triplet,
bool& default_triplet_used,
const LocalizedString& example_text,
const VcpkgPaths& paths);

FullPackageSpec check_and_get_full_package_spec(std::string&& spec_string,
FullPackageSpec check_and_get_full_package_spec(std::string spec_string,
Triplet default_triplet,
bool& default_triplet_used,
const LocalizedString& example_text,
const VcpkgPaths& paths);

Expand Down
10 changes: 6 additions & 4 deletions include/vcpkg/packagespec.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ namespace vcpkg
using std::vector<std::string>::vector;
};

InternalFeatureSet internalize_feature_list(View<std::string> fs, ImplicitDefault id);

///
/// <summary>
/// Full specification of a package. Contains all information to reference
Expand All @@ -109,12 +111,10 @@ namespace vcpkg
PackageSpec package_spec;
InternalFeatureSet features;

FullPackageSpec() = default;
FullPackageSpec(PackageSpec spec, InternalFeatureSet features)
: package_spec(std::move(spec)), features(std::move(features))
{
}
FullPackageSpec(PackageSpec spec, View<std::string> features, ImplicitDefault id);

/// Splats into individual FeatureSpec's
void expand_fspecs_to(std::vector<FeatureSpec>& oFut) const;
Expand All @@ -135,9 +135,11 @@ namespace vcpkg

/// @param id add "default" if "core" is not present
/// @return nullopt on success. On failure, caller should supplement returned string with more context.
ExpectedL<FullPackageSpec> to_full_spec(Triplet default_triplet, ImplicitDefault id) const;
ExpectedL<FullPackageSpec> to_full_spec(Triplet default_triplet,
bool& default_triplet_used,
ImplicitDefault id) const;

ExpectedL<PackageSpec> to_package_spec(Triplet default_triplet) const;
ExpectedL<PackageSpec> to_package_spec(Triplet default_triplet, bool& default_triplet_used) const;
};

Optional<std::string> parse_feature_name(ParserBase& parser);
Expand Down
2 changes: 1 addition & 1 deletion include/vcpkg/triplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace vcpkg

Triplet default_triplet(const VcpkgCmdArguments& args);
Triplet default_host_triplet(const VcpkgCmdArguments& args);
void print_default_triplet_warning(const VcpkgCmdArguments& args, View<std::string> specs);
void print_default_triplet_warning(const VcpkgCmdArguments& arg);
}

VCPKG_FORMAT_AS(vcpkg::Triplet, vcpkg::StringView);
Expand Down
Loading

0 comments on commit 823c16e

Please sign in to comment.