Skip to content

Commit

Permalink
Fix apply_patch with missing find_eol_converter
Browse files Browse the repository at this point in the history
  • Loading branch information
JonatanAntoni committed Mar 12, 2024
1 parent a86043d commit fa9cf8a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test/test_integ_default/src/mac.c text eol=cr
test/test_integ_default/src/test.c text eol=lf
test/test_integ_default/src/win.c text eol=crlf

1 change: 1 addition & 0 deletions gen-pack
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ function gen_pack {
;;
esac
fi
find_eol_converter

echo_log " "

Expand Down
1 change: 1 addition & 0 deletions test/test_integ_default/src/mac.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void mac() {}
Expand Down
2 changes: 2 additions & 0 deletions test/test_integ_default/src/win.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
void win() {
}
13 changes: 13 additions & 0 deletions test/test_integ_default/test.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@
+void test() {
+ /* some additional code */
+}
--- src/win.c
+++ src/win.c
@@ -1,2 +1,3 @@
void win() {
+ /* some additional code */
}
--- src/mac.c
+++ src/mac.c
@@ -1,2 +1,3 @@
void mac() {
+ /* some additional code */
}

48 changes: 31 additions & 17 deletions test/tests_integ.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@

DIRNAME="$(realpath "$(dirname "$0")")"

shopt -s expand_aliases

case $(uname -s) in
'Darwin')
alias "stat"="gstat"
;;
esac

setUp() {
# shellcheck disable=SC2155
export GEN_PACK_LIB="$(realpath "${DIRNAME}/../")"
Expand All @@ -35,19 +43,25 @@ test_integ_default() {

rm -rf build output

./gen_pack.sh -k

assertTrue "Pack description file missing" "[ -f build/ARM.GenPack.pdsc ]"
assertTrue "Pack checksum file missing" "[ -f build/ARM.GenPack.sha1 ]"
assertTrue "LICENSE file" "[ -f build/LICENSE ]"
assertTrue "Doc top level index missing" "[ -f build/doc/index.html ]"
assertFalse "Doxyfile found in build" "[ -f build/doc/test.dxy ]"
assertTrue "Doc index file missing" "[ -f build/doc/html/index.html ]"
assertTrue "Header file missing" "[ -f build/inc/test.h ]"
assertTrue "Source file missing" "[ -f build/src/test.c ]"
assertTrue "Pack archive missing" "[ -f output/ARM.GenPack.1.0.1-dev1.pack ]"

assertTrue "Checksum file verification failed" "cd build; sha1sum ARM.GenPack.sha1"
./gen_pack.sh --verbose -k

assertTrue "Pack description file missing" "[ -f build/ARM.GenPack.pdsc ]"
assertTrue "Pack checksum file missing" "[ -f build/ARM.GenPack.sha1 ]"
assertTrue "LICENSE file" "[ -f build/LICENSE ]"
assertTrue "Doc top level index missing" "[ -f build/doc/index.html ]"
assertFalse "Doxyfile found in build" "[ -f build/doc/test.dxy ]"
assertTrue "Doc index file missing" "[ -f build/doc/html/index.html ]"
assertTrue "Header file missing" "[ -f build/inc/test.h ]"
assertEquals "test.h seems not patched" "13" "$(stat -c "%s" build/inc/test.h)"
assertTrue "Source file missing" "[ -f build/src/test.c ]"
assertEquals "test.c seems not patched" "48" "$(stat -c "%s" build/src/test.c)"
assertTrue "Source file missing" "[ -f build/src/win.c ]"
assertEquals "win.c seems not patched" "50" "$(stat -c "%s" build/src/win.c)"
assertTrue "Source file missing" "[ -f build/src/mac.c ]"
assertEquals "mac.c seems not patched" "47" "$(stat -c "%s" build/src/mac.c)"
assertTrue "Pack archive missing" "[ -f output/ARM.GenPack.1.0.1-dev1.pack ]"

assertTrue "Checksum file verification failed" "cd build; sha1sum ARM.GenPack.sha1"

pdsc=$(cat build/ARM.GenPack.pdsc)
assertContains "$pdsc" '<release version="1.0.1-dev1">'
Expand All @@ -64,7 +78,7 @@ test_integ_with_git_release() {
git --git-dir="$(pwd)/.git" clean -fdxq
git --git-dir="$(pwd)/.git" checkout -fq v1.0.0

./gen_pack.sh -k
./gen_pack.sh --verbose -k

assertTrue "Pack description file missing" "[ -f build/ARM.GenPack.pdsc ]"
assertTrue "Pack checksum file missing" "[ -f build/ARM.GenPack.sha1 ]"
Expand Down Expand Up @@ -98,7 +112,7 @@ test_integ_with_git_prerelease() {
export GIT_COMMITTER_DATE="2022-08-04T16:00:00Z"
git --git-dir="$(pwd)/.git" tag -m "Active development ..." v1.0.0-dev v1.0.0^

./gen_pack.sh -k
./gen_pack.sh --verbose -k

assertTrue "Pack description file missing" "[ -f build/ARM.GenPack.pdsc ]"
assertTrue "Pack checksum file missing" "[ -f build/ARM.GenPack.sha1 ]"
Expand Down Expand Up @@ -127,7 +141,7 @@ test_integ_with_git_devdrop() {
git --git-dir="$(pwd)/.git" clean -fdxq
git --git-dir="$(pwd)/.git" checkout -fq main

./gen_pack.sh -k
./gen_pack.sh --verbose -k

assertTrue "Pack description file missing" "[ -f build/ARM.GenPack.pdsc ]"
assertTrue "Pack checksum file missing" "[ -f build/ARM.GenPack.sha1 ]"
Expand Down Expand Up @@ -156,7 +170,7 @@ test_integ_with_git_v2_dev() {
git --git-dir="$(pwd)/.git" clean -fdxq
git --git-dir="$(pwd)/.git" checkout -fq v2

./gen_pack.sh -k
./gen_pack.sh --verbose -k

assertTrue "Pack description file missing" "[ -f build/ARM.GenPack.pdsc ]"
assertTrue "Pack checksum file missing" "[ -f build/ARM.GenPack.sha1 ]"
Expand Down

0 comments on commit fa9cf8a

Please sign in to comment.