Skip to content

Commit 4095ce9

Browse files
committed
test: add test for shorthand syntax with options
1 parent 92ef184 commit 4095ce9

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,8 @@ CPMAddPackage("gh:jbeder/yaml-cpp#yaml-cpp-0.6.3@0.6.3")
403403
### [nlohmann/json](https://github.com/nlohmann/json)
404404

405405
```cmake
406-
CPMAddPackage("gh:nlohmann/json@3.9.1"
406+
CPMAddPackage(
407+
URI "gh:nlohmann/json@3.9.1"
407408
OPTIONS "JSON_BuildTests OFF"
408409
)
409410
```

test/integration/test_simple.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,39 @@ def test_update_single_package
8383
# ...and notably no test for adder, which must be disabled from the option override from above
8484
assert_equal ['simple', 'using-adder'], exes
8585
}
86+
update_with_option_off_and_build_with_uri_shorthand_syntax = -> {
87+
prj.create_lists_from_default_template package: <<~PACK
88+
CPMAddPackage(
89+
URI gh:cpm-cmake/testpack-adder@1.0.0
90+
OPTIONS "ADDER_BUILD_TESTS OFF"
91+
)
92+
PACK
93+
assert_success prj.configure
94+
assert_success prj.build
95+
96+
exe_dir = File.join(prj.bin_dir, 'bin')
97+
assert File.directory? exe_dir
98+
99+
exes = Dir[exe_dir + '/**/*'].filter {
100+
# on multi-configuration generators (like Visual Studio) the executables will be in bin/<Config>
101+
# also filter-out other artifacts like .pdb or .dsym
102+
!File.directory?(_1) && File.stat(_1).executable?
103+
}.map {
104+
# remove .exe extension if any (there will be one on Windows)
105+
File.basename(_1, '.exe')
106+
}.sort
107+
108+
# we should end up with two executables
109+
# * simple - the simple example from adder
110+
# * using-adder - for this project
111+
# ...and notably no test for adder, which must be disabled from the option override from above
112+
assert_equal ['simple', 'using-adder'], exes
113+
114+
}
86115

87116
create_with_commit_sha.()
88117
update_to_version_1.()
89118
update_with_option_off_and_build.()
119+
update_with_option_off_and_build_with_uri_shorthand_syntax.()
90120
end
91121
end

0 commit comments

Comments
 (0)