Skip to content

Commit

Permalink
Add override patches and test that patches are applied.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdice committed Jul 9, 2024
1 parent a29421a commit 711f4b0
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 4 deletions.
22 changes: 18 additions & 4 deletions testing/cpm/cpm_find-patch-command/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,33 @@ set(cccl_dir "${deps_dir}/cccl")
list(APPEND CMAKE_PREFIX_PATH "${cccl_dir}")

include(${rapids-cmake-dir}/cpm/init.cmake)
include(${rapids-cmake-dir}/cpm/cccl.cmake)
rapids_cpm_init()

include(${rapids-cmake-dir}/cpm/package_override.cmake)
rapids_cpm_package_override(${CMAKE_CURRENT_SOURCE_DIR}/override.json)

include(${rapids-cmake-dir}/cpm/cccl.cmake)
rapids_cpm_cccl()

if(NOT "${CCCL_ADDED}")
message(FATAL_ERROR "The found repo was used rather than downloading and patching a new version")
endif()

# Verify that the two files that we inserted into the CCCL source tree exist
# Which proves the patches in the override are properly applied
if(NOT EXISTS "${CCCL_SOURCE_DIR}/git_file_1.txt")
message(FATAL_ERROR "failed to apply CCCL first patch")
endif()

if(NOT EXISTS "${CCCL_SOURCE_DIR}/git_file_2.txt")
message(FATAL_ERROR "failed to apply CCCL second patch")
endif()

execute_process(
COMMAND ${GIT_EXECUTABLE} diff-files --quiet
RESULT_VARIABLE REPO_IS_DIRTY
COMMAND ${GIT_EXECUTABLE} diff --quiet ${tag}
RESULT_VARIABLE REPO_IS_PATCHED
WORKING_DIRECTORY "${CCCL_SOURCE_DIR}")

if(NOT ${REPO_IS_DIRTY})
if(NOT ${REPO_IS_PATCHED})
message(FATAL_ERROR "The repo was downloaded to ${CCCL_SOURCE_DIR} but not patched.")
endif()
18 changes: 18 additions & 0 deletions testing/cpm/cpm_find-patch-command/override.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"packages": {
"CCCL": {
"patches": [
{
"file": "${current_json_dir}/patches/0001-move-git-sha1.patch",
"issue": "Move git sha1",
"fixed_in": ""
},
{
"file": "${current_json_dir}/patches/0002-move-git-sha1-a-second-time.patch",
"issue": "Move git sha1 a second time",
"fixed_in": ""
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
From deacd3fafd7fcfee954ae3044ae3ab60d36a9f3a Mon Sep 17 00:00:00 2001
From: Robert Maynard <[email protected]>
Date: Wed, 31 Jan 2024 15:00:47 -0500
Subject: [PATCH 1/2] Move GIT SHA1

---
git_file_1.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 git_file_1.txt

diff --git a/git_file_1.txt b/git_file_1.txt
new file mode 100644
index 00000000..b242c360
--- /dev/null
+++ b/git_file_1.txt
@@ -0,0 +1 @@
+added file
--
2.43.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
From 3588e151030a30661b310a876f7cc450d6ca9201 Mon Sep 17 00:00:00 2001
From: Robert Maynard <[email protected]>
Date: Wed, 31 Jan 2024 15:01:21 -0500
Subject: [PATCH 2/2] Move GIT SHA1 a second time

---
git_file_2.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 git_file_2.txt

diff --git a/git_file_2.txt b/git_file_2.txt
new file mode 100644
index 00000000..fa240558
--- /dev/null
+++ b/git_file_2.txt
@@ -0,0 +1 @@
+added another file
--
2.43.0

0 comments on commit 711f4b0

Please sign in to comment.