Fix regression in x-script from fixing doskey macros. (#1337)

This commit is contained in:
Billy O'Neal 2024-02-05 12:02:09 -08:00 коммит произвёл GitHub
Родитель bdbd8dcf04
Коммит 1e8b699111
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
8 изменённых файлов: 143 добавлений и 62 удалений

Просмотреть файл

@ -161,6 +161,24 @@ endif()
include(GNUInstallDirs)
file(GLOB VCPKGLIB_BASE_SOURCES CONFIGURE_DEPENDS "src/vcpkg/base/*.cpp")
file(GLOB VCPKGLIB_SOURCES CONFIGURE_DEPENDS "src/vcpkg/*.cpp")
file(GLOB VCPKGLIB_BASE_INCLUDES CONFIGURE_DEPENDS "include/vcpkg/base/*.h" "include/vcpkg/base/fwd/*.h")
file(GLOB VCPKGLIB_INCLUDES CONFIGURE_DEPENDS "include/vcpkg/*.h" "include/vcpkg/fwd/*.h")
set(VCPKG_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.cpp")
file(GLOB VCPKG_TEST_SOURCES CONFIGURE_DEPENDS "src/vcpkg-test/*.cpp")
file(GLOB VCPKG_TEST_INCLUDES CONFIGURE_DEPENDS "include/vcpkg-test/*.h")
set(VCPKG_FUZZ_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg-fuzz/main.cpp")
set(TLS12_DOWNLOAD_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/tls12-download.c")
set(CLOSES_STDIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/closes-stdin.c")
set(CLOSES_STDOUT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/closes-stdout.c")
set(READS_STDIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/reads-stdin.c")
set(TEST_EDITOR_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/test-editor.c")
set(TEST_SCRIPT_ASSET_CACHE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/test-script-asset-cache.c")
# ====================
# === Dependencies ===
# ====================
@ -187,11 +205,6 @@ endif()
# === Target: vcpkglib ===
file(GLOB VCPKGLIB_SOURCES CONFIGURE_DEPENDS "src/vcpkg/*.cpp")
file(GLOB VCPKGLIB_BASE_SOURCES CONFIGURE_DEPENDS "src/vcpkg/base/*.cpp")
file(GLOB VCPKGLIB_INCLUDES CONFIGURE_DEPENDS "include/vcpkg/*.h" "include/vcpkg/fwd/*.h")
file(GLOB VCPKGLIB_BASE_INCLUDES CONFIGURE_DEPENDS "include/vcpkg/base/*.h" "include/vcpkg/base/fwd/*.h")
add_library(vcpkglib OBJECT
${VCPKGLIB_BASE_SOURCES}
${VCPKGLIB_SOURCES}
@ -437,7 +450,7 @@ add_custom_command(
add_custom_target(vcpkg-ps1 ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/vcpkg.ps1")
# === Target: vcpkg ===
set(VCPKG_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.cpp")
add_executable(vcpkg ${VCPKG_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
target_link_libraries(vcpkg PRIVATE vcpkglib)
@ -472,9 +485,6 @@ add_custom_target(generate-message-map
if (BUILD_TESTING)
enable_testing()
file(GLOB VCPKG_TEST_SOURCES CONFIGURE_DEPENDS "src/vcpkg-test/*.cpp")
file(GLOB VCPKG_TEST_INCLUDES CONFIGURE_DEPENDS "include/vcpkg-test/*.h")
add_executable(vcpkg-test
${VCPKG_TEST_SOURCES}
${VCPKG_TEST_INCLUDES}
@ -502,7 +512,6 @@ if (BUILD_TESTING)
endif()
# === Target: vcpkg-fuzz ===
set(VCPKG_FUZZ_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg-fuzz/main.cpp")
if(VCPKG_BUILD_FUZZING)
add_executable(vcpkg-fuzz ${VCPKG_FUZZ_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
target_link_libraries(vcpkg-fuzz PRIVATE vcpkglib)
@ -511,7 +520,7 @@ endif()
# === Target: tls12-download ===
set(TLS12_DOWNLOAD_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/tls12-download.c")
if(VCPKG_BUILD_TLS12_DOWNLOADER)
add_executable(tls12-download ${TLS12_DOWNLOAD_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET tls12-download PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
@ -523,27 +532,28 @@ endif()
if (BUILD_TESTING)
# === Target: closes-stdin ===
set(CLOSES_STDIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/closes-stdin.c")
add_executable(closes-stdin ${CLOSES_STDIN_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET closes-stdin PROPERTY PDB_NAME "closes-stdin${VCPKG_PDB_SUFFIX}")
# === Target: closes-stdout ===
set(CLOSES_STDOUT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/closes-stdout.c")
add_executable(closes-stdout ${CLOSES_STDOUT_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET closes-stdout PROPERTY PDB_NAME "closes-stdout${VCPKG_PDB_SUFFIX}")
# === Target: reads-stdin ===
set(READS_STDIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/reads-stdin.c")
add_executable(reads-stdin ${READS_STDIN_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET reads-stdin PROPERTY PDB_NAME "reads-stdin${VCPKG_PDB_SUFFIX}")
# === Target: test-editor ===
set(TEST_EDITOR_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/test-editor.c")
add_executable(test-editor ${TEST_EDITOR_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET test-editor PROPERTY PDB_NAME "test-editor${VCPKG_PDB_SUFFIX}")
# === Target: test-editor ===
add_executable(test-script-asset-cache ${TEST_SCRIPT_ASSET_CACHE_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET test-script-asset-cache PROPERTY PDB_NAME "test-script-asset-cache${VCPKG_PDB_SUFFIX}")
endif()
# === Target: format ===
@ -563,12 +573,9 @@ if(CLANG_FORMAT)
COMMAND "${CLANG_FORMAT}" -i -verbose ${VCPKG_TEST_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${VCPKG_TEST_INCLUDES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${VCPKG_FUZZ_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${TLS12_DOWNLOAD_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${CLOSES_STDIN_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${CLOSES_STDOUT_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${READS_STDIN_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${TEST_EDITOR_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${VCPKG_FUZZ_SOURCES} ${TLS12_DOWNLOAD_SOURCES}
${CLOSES_STDIN_SOURCES} ${CLOSES_STDOUT_SOURCES} ${READS_STDIN_SOURCES}
${TEST_EDITOR_SOURCES} ${TEST_SCRIPT_ASSET_CACHE_SOURCES}
)
endif()

Просмотреть файл

@ -0,0 +1,14 @@
# This port is for testing that x-script works; see test-script-asset-cache.c
vcpkg_download_distfile(
SOURCE_PATH
URLS https://example.com/hello-world.txt
SHA512 09E1E2A84C92B56C8280F4A1203C7CFFD61B162CFE987278D4D6BE9AFBF38C0E8934CDADF83751F4E99D111352BFFEFC958E5A4852C8A7A29C95742CE59288A8
FILENAME hello-world.txt
)
file(READ "${SOURCE_PATH}" CONTENTS)
if (NOT CONTENTS STREQUAL "Hello, world!\n")
message(FATAL_ERROR "Downloaded file has incorrect contents: ${CONTENTS}")
endif()
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

Просмотреть файл

@ -0,0 +1,4 @@
{
"name": "vcpkg-test-x-script",
"version-string": "1.0.0"
}

Просмотреть файл

@ -0,0 +1,5 @@
. $PSScriptRoot/../end-to-end-tests-prelude.ps1
Refresh-TestRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-test-x-script", "--x-binarysource=clear", "--overlay-ports=$PSScriptRoot/../e2e-ports", "--x-asset-sources=x-script,$TestScriptAssetCacheExe {url} {sha512} {dst};x-block-origin"))
Throw-IfFailed

Просмотреть файл

@ -6,7 +6,7 @@ $commonArgs += @(
)
# Test simple installation
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--binarycaching", "--x-binarysource=clear;files,$ArchiveRoot,write"))
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--x-binarysource=clear;files,$ArchiveRoot,write"))
Throw-IfFailed
# Test simple removal
@ -16,14 +16,14 @@ Require-FileNotExists "$installRoot/$Triplet/include"
if(-Not $IsLinux -and -Not $IsMacOS) {
# Test simple nuget installation
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--binarycaching", "--x-binarysource=clear;nuget,$NuGetRoot,readwrite"))
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--x-binarysource=clear;nuget,$NuGetRoot,readwrite"))
Throw-IfFailed
}
# Test restoring from files archive
Remove-Item -Recurse -Force $installRoot
Remove-Item -Recurse -Force $buildtreesRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config","--binarycaching","--x-binarysource=clear;files,$ArchiveRoot,read"))
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--x-binarysource=clear;files,$ArchiveRoot,read"))
Throw-IfFailed
Require-FileExists "$installRoot/$Triplet/include/hello-1.h"
Require-FileNotExists "$buildtreesRoot/vcpkg-hello-world-1/src"
@ -32,7 +32,7 @@ Require-FileExists "$buildtreesRoot/detect_compiler"
# Test --no-binarycaching
Remove-Item -Recurse -Force $installRoot
Remove-Item -Recurse -Force $buildtreesRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config","--no-binarycaching","--x-binarysource=clear;files,$ArchiveRoot,read"))
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--no-binarycaching", "--x-binarysource=clear;files,$ArchiveRoot,read"))
Throw-IfFailed
Require-FileExists "$installRoot/$Triplet/include/hello-1.h"
Require-FileExists "$buildtreesRoot/vcpkg-hello-world-1/src"
@ -41,7 +41,7 @@ Require-FileExists "$buildtreesRoot/detect_compiler"
# Test --editable
Remove-Item -Recurse -Force $installRoot
Remove-Item -Recurse -Force $buildtreesRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config","--editable","--x-binarysource=clear;files,$ArchiveRoot,read"))
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--editable", "--x-binarysource=clear;files,$ArchiveRoot,read"))
Throw-IfFailed
Require-FileExists "$installRoot/$Triplet/include/hello-1.h"
Require-FileExists "$buildtreesRoot/vcpkg-hello-world-1/src"
@ -51,7 +51,7 @@ if(-Not $IsLinux -and -Not $IsMacOS) {
# Test restoring from nuget
Remove-Item -Recurse -Force $installRoot
Remove-Item -Recurse -Force $buildtreesRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--binarycaching", "--x-binarysource=clear;nuget,$NuGetRoot"))
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--x-binarysource=clear;nuget,$NuGetRoot"))
Throw-IfFailed
Require-FileExists "$installRoot/$Triplet/include/hello-1.h"
Require-FileNotExists "$buildtreesRoot/vcpkg-hello-world-1/src"
@ -72,7 +72,7 @@ if(-Not $IsLinux -and -Not $IsMacOS) {
Throw-IfFailed
Remove-Item -Recurse -Force $NuGetRoot -ErrorAction SilentlyContinue
mkdir $NuGetRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-hello-world-2", "vcpkg-cmake", "vcpkg-cmake-config", "--binarycaching", "--x-binarysource=clear;nuget,$NuGetRoot2;nuget,$NuGetRoot,write"))
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-hello-world-2", "vcpkg-cmake", "vcpkg-cmake-config", "--x-binarysource=clear;nuget,$NuGetRoot2;nuget,$NuGetRoot,write"))
Throw-IfFailed
Require-FileExists "$installRoot/$Triplet/include/hello-1.h"
Require-FileExists "$installRoot/$Triplet/include/hello-2.h"

Просмотреть файл

@ -60,21 +60,21 @@ if ([string]::IsNullOrWhitespace($VcpkgRoot)) {
$VcpkgRoot = (Get-Item $VcpkgRoot).FullName
[string]$executableExtension = ''
if ($IsWindows)
{
$executableExtension = '.exe'
}
if ([string]::IsNullOrEmpty($VcpkgExe))
{
if ($IsWindows)
{
$VcpkgExe = Get-Item './vcpkg.exe'
}
else
{
$VcpkgExe = Get-Item './vcpkg'
}
$VcpkgExe = "./vcpkg$executableExtension"
}
$VcpkgItem = Get-Item $VcpkgExe
$VcpkgExe = $VcpkgItem.FullName
$VcpkgPs1 = Join-Path $VcpkgItem.Directory "vcpkg.ps1"
$TestScriptAssetCacheExe = Join-Path $VcpkgItem.Directory "test-script-asset-cache"
[Array]$AllTests = Get-ChildItem $PSScriptRoot/end-to-end-tests-dir/*.ps1
if ($Filter -ne $Null) {
@ -84,17 +84,18 @@ $n = 1
$m = $AllTests.Count
$envvars_clear = @(
"VCPKG_FORCE_SYSTEM_BINARIES",
"VCPKG_FORCE_DOWNLOADED_BINARIES",
"VCPKG_DEFAULT_HOST_TRIPLET",
"VCPKG_DEFAULT_TRIPLET",
"VCPKG_BINARY_SOURCES",
"VCPKG_OVERLAY_PORTS",
"VCPKG_OVERLAY_TRIPLETS",
"VCPKG_KEEP_ENV_VARS",
"VCPKG_ROOT",
"VCPKG_FEATURE_FLAGS",
"VCPKG_DISABLE_METRICS"
'VCPKG_BINARY_SOURCES',
'VCPKG_DEFAULT_HOST_TRIPLET',
'VCPKG_DEFAULT_TRIPLET',
'VCPKG_DISABLE_METRICS',
'VCPKG_FEATURE_FLAGS',
'VCPKG_FORCE_DOWNLOADED_BINARIES',
'VCPKG_FORCE_SYSTEM_BINARIES',
'VCPKG_KEEP_ENV_VARS',
'VCPKG_OVERLAY_PORTS',
'VCPKG_OVERLAY_TRIPLETS',
'VCPKG_ROOT',
'X_VCPKG_ASSET_SOURCES'
)
$envvars = $envvars_clear + @("VCPKG_DOWNLOADS", "X_VCPKG_REGISTRIES_CACHE", "PATH")
@ -128,7 +129,7 @@ foreach ($Test in $AllTests)
{
foreach ($var in $envvars)
{
if ($envbackup[$var] -eq $null)
if ($null -eq $envbackup[$var])
{
if (Test-Path "Env:\$var")
{

Просмотреть файл

@ -0,0 +1,49 @@
#define _CRT_SECURE_NO_WARNINGS
#include <stddef.h>
#include <stdio.h>
#include <string.h>
static const char expected_uri[] = "https://example.com/hello-world.txt";
static const char expected_sha[] = "09e1e2a84c92b56c8280f4a1203c7cffd61b162cfe987278d4d6be9afbf38c0e8934cdadf83751f4e99"
"d111352bffefc958e5a4852c8a7a29c95742ce59288a8";
static const char result_data[] = "Hello, world!\n";
int main(int argc, char** argv)
{
if (argc != 4)
{
puts("Bad argument count; usage: test-script-asset-cache {url} {sha512} {dst}");
return 1;
}
if (strcmp(argv[1], expected_uri) != 0)
{
printf("Bad argument 1; expected url: %s, got %s\n", expected_uri, argv[1]);
return 1;
}
if (strcmp(argv[2], expected_sha) != 0)
{
printf("Bad argument 2; expected sha512: %s, got %s\n", expected_sha, argv[2]);
return 1;
}
FILE* fp = fopen(argv[3], "wb");
if (!fp)
{
puts("fopen failed");
return 1;
}
if (fwrite(result_data, 1, sizeof(result_data) - 1, fp) != sizeof(result_data) - 1)
{
puts("fputs failed");
fclose(fp);
return 1;
}
fclose(fp);
return 0;
}

Просмотреть файл

@ -959,20 +959,21 @@ namespace vcpkg
const auto escaped_url = Command(urls[0]).extract();
const auto escaped_sha512 = Command(*hash).extract();
const auto escaped_dpath = Command(download_path_part_path).extract();
auto cmd = Command{api_stable_format(*script, [&](std::string& out, StringView key) {
if (key == "url")
{
Strings::append(out, escaped_url);
}
else if (key == "sha512")
{
Strings::append(out, escaped_sha512);
}
else if (key == "dst")
{
Strings::append(out, escaped_dpath);
}
}).value_or_exit(VCPKG_LINE_INFO)};
Command cmd;
cmd.raw_arg(api_stable_format(*script, [&](std::string& out, StringView key) {
if (key == "url")
{
Strings::append(out, escaped_url);
}
else if (key == "sha512")
{
Strings::append(out, escaped_sha512);
}
else if (key == "dst")
{
Strings::append(out, escaped_dpath);
}
}).value_or_exit(VCPKG_LINE_INFO));
RedirectedProcessLaunchSettings settings;
settings.environment = get_clean_environment();