diff options
Diffstat (limited to 'Tests')
20 files changed, 103 insertions, 2 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index dd786b8..6bea788 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -619,6 +619,7 @@ endif() if(CMAKE_GENERATOR MATCHES "^Visual Studio (1[6-9]|[2-9][0-9])") add_RunCMake_test(VsDotnetSdk) + add_RunCMake_test(VsNugetPackageRestore) endif() if(XCODE_VERSION) diff --git a/Tests/RunCMake/CMakePresetsBuild/Good.json.in b/Tests/RunCMake/CMakePresetsBuild/Good.json.in index c7f318c..568907c 100644 --- a/Tests/RunCMake/CMakePresetsBuild/Good.json.in +++ b/Tests/RunCMake/CMakePresetsBuild/Good.json.in @@ -1,5 +1,5 @@ { - "version": 2, + "version": 4, "configurePresets": [ { "name": "default", @@ -78,6 +78,12 @@ "name": "singleTarget", "inherits": "build-default", "targets": "good" + }, + { + "name": "initResolve", + "inherits": "build-default", + "targets": "good", + "resolvePackageReferences": "off" } ] } diff --git a/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake index b37c770..2fe0407 100644 --- a/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake @@ -70,7 +70,7 @@ else() set(Good_json_jobs [["jobs": 0,]]) endif() -run_cmake_build_presets(Good "default;other" "build-other;withEnvironment;noEnvironment;macros;vendorObject;singleTarget") +run_cmake_build_presets(Good "default;other" "build-other;withEnvironment;noEnvironment;macros;vendorObject;singleTarget;initResolve") run_cmake_build_presets(InvalidConfigurePreset "default" "badConfigurePreset") run_cmake_build_presets(Condition "default" "enabled;disabled") diff --git a/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-result.txt b/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-stderr.txt b/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-stderr.txt new file mode 100644 index 0000000..4811bea --- /dev/null +++ b/Tests/RunCMake/CommandLine/build-invalid-package-resolve-arg-stderr.txt @@ -0,0 +1 @@ +^Usage: cmake --build <dir> +\[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/VsNugetPackageRestore/CMakeLists.txt b/Tests/RunCMake/VsNugetPackageRestore/CMakeLists.txt new file mode 100644 index 0000000..d8200fc --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.22) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/VsNugetPackageRestore/Package/CMakeLists.txt b/Tests/RunCMake/VsNugetPackageRestore/Package/CMakeLists.txt new file mode 100644 index 0000000..56920d9 --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/Package/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.12) + +project(NuGetTestProject VERSION 1.0.0 LANGUAGES CSharp) + +add_library(NuGetPackage SHARED "Library.cs") +set_target_properties(NuGetPackage PROPERTIES + VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.7.2" + VS_DOTNET_REFERENCES "System") +install(TARGETS NuGetPackage) + +set(CPACK_GENERATOR "NuGet") +set(CPACK_PACKAGE_NAME "NuGetTestProject") +set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") +set(CPACK_PACKAGE_DESCRIPTION "Package to test automatic NuGet package restore.") +set(CPACK_PACKAGE_VENDOR "CMake.org") + +include(CPack) diff --git a/Tests/RunCMake/VsNugetPackageRestore/Package/Library.cs b/Tests/RunCMake/VsNugetPackageRestore/Package/Library.cs new file mode 100644 index 0000000..d9ae85a --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/Package/Library.cs @@ -0,0 +1,9 @@ +using System; + +namespace CMake +{ + public class NuGetTest + { + public static int GetNumber() => 42; + } +} diff --git a/Tests/RunCMake/VsNugetPackageRestore/Program.cs b/Tests/RunCMake/VsNugetPackageRestore/Program.cs new file mode 100644 index 0000000..681461f --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/Program.cs @@ -0,0 +1,14 @@ +using System; +using CMake; + +namespace Test +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine(NuGetTest.GetNumber()); + Console.ReadKey(); + } + } +} diff --git a/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/.nupkg.metadata b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/.nupkg.metadata new file mode 100644 index 0000000..6a87d0a --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/.nupkg.metadata @@ -0,0 +1,5 @@ +{ + "version": 2, + "contentHash": "2sG1Ws4da8r6qj7rUAZ1GaOjkELonH0X+vR9yfDwgg+QxG0cpRIfGqEXKAkGT+UCwU24ogJcm8IA9dXv5zmLXg==", + "source": null +} diff --git a/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg Binary files differnew file mode 100644 index 0000000..5569a29 --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg diff --git a/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg.sha512 b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg.sha512 new file mode 100644 index 0000000..5526b76 --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.1.0.0.nupkg.sha512 @@ -0,0 +1 @@ +2sG1Ws4da8r6qj7rUAZ1GaOjkELonH0X+vR9yfDwgg+QxG0cpRIfGqEXKAkGT+UCwU24ogJcm8IA9dXv5zmLXg== diff --git a/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.nuspec b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.nuspec new file mode 100644 index 0000000..9a943a8 --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/Repository/NuGetTestProject/1.0.0/nugettestproject.nuspec @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> + <metadata> + <id>NuGetTestProject</id> + <version>1.0.0</version> + <authors>CMake.org</authors> + <requireLicenseAcceptance>false</requireLicenseAcceptance> + <description>Package to test automatic NuGet package restore.</description> + <summary>NuGetTestProject built using CMake</summary> + </metadata> +</package> diff --git a/Tests/RunCMake/VsNugetPackageRestore/RunCMakeTest.cmake b/Tests/RunCMake/VsNugetPackageRestore/RunCMakeTest.cmake new file mode 100644 index 0000000..625167c --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/RunCMakeTest.cmake @@ -0,0 +1,12 @@ +cmake_policy(SET CMP0053 NEW) +include(RunCMake) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/VsNugetPackageRestore) +run_cmake(VsNugetPackageRestore) + +set(RunCMake_TEST_NO_CLEAN 1) +run_cmake_command(vs-nuget-package-restore-off ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --resolve-package-references=off) +run_cmake_command(vs-nuget-package-restore-only ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --resolve-package-references=only) +run_cmake_command(vs-nuget-package-restore-on ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --resolve-package-references=on) +run_cmake_command(vs-nuget-package-restore-wrong ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --resolve-package-references=wrong) +set(RunCMake_TEST_NO_CLEAN 0) diff --git a/Tests/RunCMake/VsNugetPackageRestore/VsNugetPackageRestore.cmake b/Tests/RunCMake/VsNugetPackageRestore/VsNugetPackageRestore.cmake new file mode 100644 index 0000000..a0227df --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/VsNugetPackageRestore.cmake @@ -0,0 +1,9 @@ +enable_language(CSharp) + +add_executable(TestProgram "Program.cs") +configure_file("nuget.config.in" "nuget.config") +set_target_properties(TestProgram PROPERTIES + VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.7.2" + VS_DOTNET_REFERENCES "System" + VS_PACKAGE_REFERENCES "NuGetTestProject_1.0.0" +) diff --git a/Tests/RunCMake/VsNugetPackageRestore/nuget.config.in b/Tests/RunCMake/VsNugetPackageRestore/nuget.config.in new file mode 100644 index 0000000..2e54c8f --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/nuget.config.in @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <packageSources> + <clear /> + <add key="local" value="@CMAKE_CURRENT_SOURCE_DIR@/Repository/" /> + </packageSources> +</configuration> diff --git a/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-result.txt b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-stderr.txt b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-off-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-result.txt b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-stderr.txt b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-stderr.txt new file mode 100644 index 0000000..4811bea --- /dev/null +++ b/Tests/RunCMake/VsNugetPackageRestore/vs-nuget-package-restore-wrong-stderr.txt @@ -0,0 +1 @@ +^Usage: cmake --build <dir> +\[options\] \[-- \[native-options\]\] |