Files
CPM.cmake/test/integration/test_fetchcontent_compatibility.rb

44 lines
1.1 KiB
Ruby
Raw Normal View History

require_relative './lib'
# Tests FetchContent overriding with CPM
class FetchContentCompatibility < IntegrationTest
def setup
@cache_dir = File.join(cur_test_dir, 'cpmcache')
ENV['CPM_SOURCE_CACHE'] = @cache_dir
end
def test_add_dependency_cpm_and_fetchcontent
Add file locking to support parallel runs. (#427) * Add file locking to support parallel runs. * Fixed formatting. * Prevent double locking file. * Fix SegFault from test 2. * Remove unnecessary debugging messages. * Lock the package directory rather than the cache directory. Only synchronize if CPM_SOURCE_CACHE is defined. * Lock the version specific cache entry rather than the package specific entry. * Remove unnecessary arguments in conditional statements. * Change back to locking entire cache directory. * Only check CPM_HAS_CACHE_LOCK. * Lock on a per-package basis rather than the entire cache. * Clean up the locked file. * Unlock then remove to fix Windows. * Specify use of cmake.lock as the lock file. * - Changed CPM_HAS_CACHE_LOCK to ${CPM_ARGS_NAME}_CPM_HAS_CACHE_LOCK. - Removed redundant variable initialization. * Add unit test. * Actually test if resulting git cache is clean in unit test. * - Added comments - Fixed formatting - Removed unnecessary imports * convert parallelism test to integration test * remove comment * - Removed now unnecessary variable. - Only delete file instead of unlocking it then deleting it. * Forgot to change variable name. * Add similar changes to the missed section. * Fixed formatting. * Unlock the file, but do not delete it. * Only unlock the file if it exists. * Changed cache.cmake test to ignore non-directory entries. * Integration test lib make_project: * keyword args * 'name' arg to allow multiple projects from the same test * - Moved checks to function. - Fixed small grammatical errors. * - Fix formatting * Switch to snake case. --------- Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com> Co-authored-by: Lars Melchior <lars.melchior@gmail.com> Co-authored-by: Borislav Stanimirov <b.stanimirov@abv.bg>
2023-01-28 08:36:44 -05:00
prj = make_project from_template: 'using-adder'
prj.create_lists_from_default_template package: <<~PACK
CPMAddPackage(
NAME testpack-adder
GITHUB_REPOSITORY cpm-cmake/testpack-adder
VERSION 1.0.0
OPTIONS "ADDER_BUILD_TESTS OFF"
)
# should have no effect, as we added the dependency using CPM
FetchContent_Declare(
testpack-adder
GIT_REPOSITORY https://github.com/cpm-cmake/testpack-adder
GIT_TAG v1.0.0
)
FetchContent_MakeAvailable(testpack-adder)
PACK
# configure with unpopulated cache
assert_success prj.configure
assert_success prj.build
# cache is populated
assert_true File.exist?(File.join(@cache_dir, "testpack-adder"))
# configure with populated cache
assert_success prj.configure
assert_success prj.build
end
end