From d10daf7b99b706739666eac86d3454b6a4c21daf Mon Sep 17 00:00:00 2001 From: Simon Gene Gottlieb Date: Tue, 26 Mar 2024 11:25:45 +0100 Subject: [PATCH] test: add test for shorthand syntax with options --- README.md | 3 ++- test/integration/test_simple.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 349c25b9..c30138cc 100644 --- a/README.md +++ b/README.md @@ -403,7 +403,8 @@ CPMAddPackage("gh:jbeder/yaml-cpp#yaml-cpp-0.6.3@0.6.3") ### [nlohmann/json](https://github.com/nlohmann/json) ```cmake -CPMAddPackage("gh:nlohmann/json@3.9.1" +CPMAddPackage( + URI "gh:nlohmann/json@3.9.1" OPTIONS "JSON_BuildTests OFF" ) ``` diff --git a/test/integration/test_simple.rb b/test/integration/test_simple.rb index 33fe3785..6deef26f 100644 --- a/test/integration/test_simple.rb +++ b/test/integration/test_simple.rb @@ -83,9 +83,39 @@ def test_update_single_package # ...and notably no test for adder, which must be disabled from the option override from above assert_equal ['simple', 'using-adder'], exes } + update_with_option_off_and_build_with_uri_shorthand_syntax = -> { + prj.create_lists_from_default_template package: <<~PACK + CPMAddPackage( + URI gh:cpm-cmake/testpack-adder@1.0.0 + OPTIONS "ADDER_BUILD_TESTS OFF" + ) + PACK + assert_success prj.configure + assert_success prj.build + + exe_dir = File.join(prj.bin_dir, 'bin') + assert File.directory? exe_dir + + exes = Dir[exe_dir + '/**/*'].filter { + # on multi-configuration generators (like Visual Studio) the executables will be in bin/ + # also filter-out other artifacts like .pdb or .dsym + !File.directory?(_1) && File.stat(_1).executable? + }.map { + # remove .exe extension if any (there will be one on Windows) + File.basename(_1, '.exe') + }.sort + + # we should end up with two executables + # * simple - the simple example from adder + # * using-adder - for this project + # ...and notably no test for adder, which must be disabled from the option override from above + assert_equal ['simple', 'using-adder'], exes + + } create_with_commit_sha.() update_to_version_1.() update_with_option_off_and_build.() + update_with_option_off_and_build_with_uri_shorthand_syntax.() end end