Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg] Turn on tests in CI. #11239

Merged
merged 15 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scripts/azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ variables:
linux-pool: 'PrLin-2020-05-07'

jobs:
- template: windows/run-tests.yml
parameters:
poolName: $(windows-pool)

- template: windows/azure-pipelines.yml
parameters:
triplet: x86-windows
Expand Down
3 changes: 3 additions & 0 deletions scripts/azure-pipelines/linux/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
displayName: 'Build vcpkg'
inputs:
filePath: bootstrap-vcpkg.sh
arguments: "-buildTests"
- bash: toolsrc/build.rel/vcpkg-test
displayName: 'Run vcpkg tests'
- powershell: |
$skipList = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "x64-linux" -BaselineFile "$(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt"
mkdir $(System.ArtifactsDirectory)/xml-results
Expand Down
4 changes: 3 additions & 1 deletion scripts/azure-pipelines/osx/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ jobs:
displayName: 'Build vcpkg'
inputs:
filePath: bootstrap-vcpkg.sh
arguments: '-allowAppleClang'
arguments: '-buildTests'
- bash: toolsrc/build.rel/vcpkg-test
displayName: 'Run vcpkg tests'
- powershell: |
$skip_list = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "x64-osx" -BaselineFile "$(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt"
mkdir $(System.ArtifactsDirectory)/xml-results
Expand Down
25 changes: 25 additions & 0 deletions scripts/azure-pipelines/windows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
#
# Builds and runs vcpkg-test.exe for PRs and CIs.

jobs:
- job: windows_tests
pool:
name: ${{ parameters.poolName }}
steps:
- task: CmdLine@2
displayName: "Build and Test vcpkg"
inputs:
script: |
:: TRANSITION, get these tools on the VMs next time we roll them
call .\bootstrap-vcpkg.bat
.\vcpkg.exe fetch cmake
.\vcpkg.exe fetch ninja
set PATH=downloads\tools\cmake-3.14.0-windows\cmake-3.14.0-win32-x86\bin;downloads\tools\ninja-1.10.0-windows;%PATH%
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x86 -host_arch=x86
rmdir /s /q build.x86.debug > nul 2> nul
cmake.exe -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DVCPKG_DEVELOPMENT_WARNINGS=ON -DVCPKG_WARNINGS_AS_ERRORS=ON -DVCPKG_BUILD_FUZZING=ON -B build.x86.debug -S toolsrc
ninja.exe -C build.x86.debug
build.x86.debug\vcpkg-test.exe
failOnStderr: true
5 changes: 4 additions & 1 deletion scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fi
vcpkgDisableMetrics="OFF"
vcpkgUseSystem=false
vcpkgAllowAppleClang=false
vcpkgBuildTests="OFF"
for var in "$@"
do
if [ "$var" = "-disableMetrics" -o "$var" = "--disableMetrics" ]; then
Expand All @@ -26,6 +27,8 @@ do
vcpkgUseSystem=true
elif [ "$var" = "-allowAppleClang" -o "$var" = "--allowAppleClang" ]; then
vcpkgAllowAppleClang=true
elif [ "$var" = "-buildTests" ]; then
vcpkgBuildTests="ON"
elif [ "$var" = "-help" -o "$var" = "--help" ]; then
echo "Usage: ./bootstrap-vcpkg.sh [options]"
echo
Expand Down Expand Up @@ -240,7 +243,7 @@ buildDir="$vcpkgRootDir/toolsrc/build.rel"
rm -rf "$buildDir"
mkdir -p "$buildDir"

(cd "$buildDir" && CXX="$CXX" "$cmakeExe" .. -DCMAKE_BUILD_TYPE=Release -G "Ninja" "-DCMAKE_MAKE_PROGRAM=$ninjaExe" "-DBUILD_TESTING=OFF" "-DVCPKG_DEVELOPMENT_WARNINGS=OFF" "-DVCPKG_DISABLE_METRICS=$vcpkgDisableMetrics" "-DVCPKG_ALLOW_APPLE_CLANG=$vcpkgAllowAppleClang") || exit 1
(cd "$buildDir" && CXX="$CXX" "$cmakeExe" .. -DCMAKE_BUILD_TYPE=Release -G "Ninja" "-DCMAKE_MAKE_PROGRAM=$ninjaExe" "-DBUILD_TESTING=$vcpkgBuildTests" "-DVCPKG_DEVELOPMENT_WARNINGS=OFF" "-DVCPKG_DISABLE_METRICS=$vcpkgDisableMetrics" "-DVCPKG_ALLOW_APPLE_CLANG=$vcpkgAllowAppleClang") || exit 1
(cd "$buildDir" && "$cmakeExe" --build .) || exit 1

rm -rf "$vcpkgRootDir/vcpkg"
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if(MSVC)
if(VCPKG_DEVELOPMENT_WARNINGS)
string(REGEX REPLACE "[-/]W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

add_compile_options(-W4)
add_compile_options(-W4 -analyze)
if(VCPKG_COMPILER STREQUAL "clang")
add_compile_options(-Wmissing-prototypes -Wno-missing-field-initializers)
endif()
Expand Down
4 changes: 2 additions & 2 deletions toolsrc/include/catch2/catch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11282,10 +11282,10 @@ namespace Catch {

Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) {
auto trimmed = [&] (size_t start, size_t end) {
while (names[start] == ',' || isspace(names[start])) {
while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) {
++start;
}
while (names[end] == ',' || isspace(names[end])) {
while (names[end] == ',' || isspace(static_cast<unsigned char>(names[end]))) {
--end;
}
return names.substr(start, end - start + 1);
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/include/pch.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <vcpkg/pragmas.h>
#include <vcpkg/base/pragmas.h>

#if defined(_WIN32)
#define NOMINMAX
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/include/vcpkg-test/util.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <catch2/catch.hpp>
#include <vcpkg/pragmas.h>
#include <vcpkg/base/pragmas.h>

#include <vcpkg/base/files.h>
#include <vcpkg/statusparagraph.h>
Expand Down
9 changes: 1 addition & 8 deletions toolsrc/include/vcpkg/base/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include <vcpkg/base/parse.h>
#include <vcpkg/base/stringview.h>

#include <functional>
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -148,11 +148,6 @@ namespace vcpkg::Json
return this->underlying_[idx];
}

void sort(const std::function<bool(const Value&, const Value&)>& lt)
{
std::sort(this->begin(), this->end(), std::ref(lt));
}

Array clone() const noexcept;

iterator begin() { return underlying_.begin(); }
Expand Down Expand Up @@ -205,8 +200,6 @@ namespace vcpkg::Json

std::size_t size() const noexcept { return this->underlying_.size(); }

void sort_keys(const std::function<bool(StringView, StringView)>& lt) noexcept;

Object clone() const noexcept;

struct const_iterator
Expand Down
22 changes: 7 additions & 15 deletions toolsrc/include/vcpkg/base/optional.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <vcpkg/base/pragmas.h>

#include <vcpkg/base/lineinfo.h>

#include <type_traits>
Expand All @@ -19,9 +21,7 @@ namespace vcpkg
template<class T, bool B = std::is_copy_constructible<T>::value>
struct OptionalStorage
{
#if defined(_WIN32)
#pragma warning(suppress : 26495)
#endif
VCPKG_MSVC_WARNING(suppress : 26495)
constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() {}
constexpr OptionalStorage(const T& t) : m_is_present(true), m_t(t) {}
constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) {}
Expand All @@ -31,17 +31,13 @@ namespace vcpkg
if (m_is_present) m_t.~T();
}

#if defined(_WIN32)
#pragma warning(suppress : 26495)
#endif
VCPKG_MSVC_WARNING(suppress : 26495)
OptionalStorage(const OptionalStorage& o) : m_is_present(o.m_is_present), m_inactive()
{
if (m_is_present) new (&m_t) T(o.m_t);
}

#if defined(_WIN32)
#pragma warning(suppress : 26495)
#endif
VCPKG_MSVC_WARNING(suppress : 26495)
OptionalStorage(OptionalStorage&& o) noexcept : m_is_present(o.m_is_present), m_inactive()
{
if (m_is_present)
Expand Down Expand Up @@ -109,9 +105,7 @@ namespace vcpkg
template<class T>
struct OptionalStorage<T, false>
{
#if defined(_WIN32)
#pragma warning(suppress : 26495)
#endif
VCPKG_MSVC_WARNING(suppress : 26495)
constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() {}
constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) {}

Expand All @@ -120,9 +114,7 @@ namespace vcpkg
if (m_is_present) m_t.~T();
}

#if defined(_WIN32)
#pragma warning(suppress : 26495)
#endif
VCPKG_MSVC_WARNING(suppress : 26495)
OptionalStorage(OptionalStorage&& o) noexcept : m_is_present(o.m_is_present), m_inactive()
{
if (m_is_present)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,19 @@
// [[nodiscard]] is not recognized before GCC version 7
#pragma GCC diagnostic ignored "-Wattributes"
#endif

#if defined(_MSC_VER)
#include <sal.h>
#endif

#ifndef _Analysis_assume_
#define _Analysis_assume_(...)
#endif

#ifdef _MSC_VER
#define VCPKG_MSVC_WARNING(...) __pragma(warning(__VA_ARGS__))
#define GCC_DIAGNOSTIC(...)
#else
#define VCPKG_MSVC_WARNING(...)
#define GCC_DIAGNOSTIC(...) _Pragma("diagnostic " #__VA_ARGS__)
#endif
3 changes: 2 additions & 1 deletion toolsrc/include/vcpkg/base/strings.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#pragma once

#include <vcpkg/base/pragmas.h>

#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/stringliteral.h>
#include <vcpkg/base/stringview.h>
#include <vcpkg/base/view.h>
#include <vcpkg/pragmas.h>

#include <vector>

Expand Down
5 changes: 3 additions & 2 deletions toolsrc/include/vcpkg/dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <vcpkg/vcpkgpaths.h>

#include <functional>
#include <map>
#include <vector>

namespace vcpkg::Graphs
Expand Down Expand Up @@ -50,7 +51,7 @@ namespace vcpkg::Dependencies
InstallPlanAction(const PackageSpec& spec,
const SourceControlFileLocation& scfl,
const RequestType& request_type,
std::unordered_map<std::string, std::vector<FeatureSpec>>&& dependencies);
std::map<std::string, std::vector<FeatureSpec>>&& dependencies);

std::string displayname() const;
const std::string& public_abi() const;
Expand All @@ -64,7 +65,7 @@ namespace vcpkg::Dependencies
RequestType request_type;
Build::BuildPackageOptions build_options;

std::unordered_map<std::string, std::vector<FeatureSpec>> feature_dependencies;
std::map<std::string, std::vector<FeatureSpec>> feature_dependencies;
std::vector<PackageSpec> package_dependencies;
std::vector<std::string> feature_list;

Expand Down
4 changes: 2 additions & 2 deletions toolsrc/include/vcpkg/statusparagraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <vcpkg/binaryparagraph.h>

#include <unordered_map>
#include <map>

namespace vcpkg
{
Expand Down Expand Up @@ -56,7 +56,7 @@ namespace vcpkg

const PackageSpec& spec() const { return core->package.spec; }
std::vector<PackageSpec> dependencies() const;
std::unordered_map<std::string, std::vector<FeatureSpec>> feature_dependencies() const;
std::map<std::string, std::vector<FeatureSpec>> feature_dependencies() const;

const StatusParagraph* core;
std::vector<const StatusParagraph*> features;
Expand Down
5 changes: 2 additions & 3 deletions toolsrc/src/vcpkg-test/plan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"});
}

Expand Down
18 changes: 7 additions & 11 deletions toolsrc/src/vcpkg-test/system.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define _POSIX_C_SOURCE 200112L
#include <catch2/catch.hpp>

#include <string>
Expand Down Expand Up @@ -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);
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion toolsrc/src/vcpkg-test/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 2 additions & 9 deletions toolsrc/src/vcpkg.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
#if defined(_MSC_VER) && _MSC_VER < 1911
// [[nodiscard]] is not recognized before VS 2017 version 15.3
#pragma warning(disable : 5030)
#endif

#if defined(__GNUC__) && __GNUC__ < 7
// [[nodiscard]] is not recognized before GCC version 7
#pragma GCC diagnostic ignored "-Wattributes"
#endif
#include <vcpkg/base/pragmas.h>

#if defined(_WIN32)
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

Expand Down
1 change: 1 addition & 0 deletions toolsrc/src/vcpkg/base/downloads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace vcpkg::Downloads
url_path,
target_file_path,
std::to_string(err));
_Analysis_assume_(f != nullptr);

auto hSession = WinHttpOpen(L"vcpkg/1.0",
IsWindows8Point1OrGreater() ? WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/src/vcpkg/base/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace vcpkg::Files
constexpr auto all_write = perms::group_write | perms::owner_write | perms::others_write;
permissions = perms::all & ~all_write;
}
else if (ft != file_type::none && ft != file_type::none)
else if (ft != file_type::none)
{
permissions = perms::all;
}
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/src/vcpkg/base/strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace vcpkg::Strings::details
{
// To disambiguate between two overloads
static bool is_space(const char c) { return std::isspace(c) != 0; }
static bool is_space(const char c) { return std::isspace(static_cast<unsigned char>(c)) != 0; }

// Avoids C4244 warnings because of char<->int conversion that occur when using std::tolower()
static char tolower_char(const char c) { return (c < 'A' || c > 'Z') ? c : c - 'A' + 'a'; }
Expand Down
Loading