mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Fix oopsies, fix and add test for ynh_setup_source with patch
This commit is contained in:
parent
d11d26bdb4
commit
4acfbdeade
3 changed files with 24 additions and 8 deletions
|
@ -217,11 +217,13 @@ ynh_setup_source () {
|
|||
fi
|
||||
|
||||
# Apply patches
|
||||
if (( $(find $YNH_APP_BASEDIR/sources/patches/ -type f -name "${source_id}-*.patch" 2> /dev/null | wc --lines) > "0" ))
|
||||
local patches_folder=$(realpath $YNH_APP_BASEDIR/sources/patches/)
|
||||
if (( $(find $patches_folder -type f -name "${source_id}-*.patch" 2> /dev/null | wc --lines) > "0" ))
|
||||
then
|
||||
(cd "$dest_dir"
|
||||
for p in $YNH_APP_BASEDIR/sources/patches/${source_id}-*.patch
|
||||
for p in $patches_folder/${source_id}-*.patch
|
||||
do
|
||||
echo $p
|
||||
patch --strip=1 < $p
|
||||
done) || ynh_die --message="Unable to apply patches"
|
||||
fi
|
||||
|
|
|
@ -28,7 +28,6 @@ ynhtest_setup_source_nominal() {
|
|||
test -e "$final_path/index.html"
|
||||
}
|
||||
|
||||
|
||||
ynhtest_setup_source_nominal_upgrade() {
|
||||
final_path="$(mktemp -d -p $VAR_WWW)"
|
||||
_make_dummy_src > ../conf/dummy.src
|
||||
|
@ -36,7 +35,6 @@ ynhtest_setup_source_nominal_upgrade() {
|
|||
ynh_setup_source --dest_dir="$final_path" --source_id="dummy"
|
||||
|
||||
test "$(cat $final_path/index.html)" == "Lorem Ipsum"
|
||||
echo $?
|
||||
|
||||
# Except index.html to get overwritten during next ynh_setup_source
|
||||
echo "IEditedYou!" > $final_path/index.html
|
||||
|
@ -63,3 +61,21 @@ ynhtest_setup_source_with_keep() {
|
|||
test "$(cat $final_path/index.html)" == "IEditedYou!"
|
||||
test "$(cat $final_path/test.txt)" == "IEditedYou!"
|
||||
}
|
||||
|
||||
ynhtest_setup_source_with_patch() {
|
||||
final_path="$(mktemp -d -p $VAR_WWW)"
|
||||
_make_dummy_src > ../conf/dummy.src
|
||||
|
||||
mkdir -p ../sources/patches
|
||||
cat > ../sources/patches/dummy-index.html.patch << EOF
|
||||
--- a/index.html
|
||||
+++ b/index.html
|
||||
@@ -1 +1,1 @@
|
||||
-Lorem Ipsum
|
||||
+Lorem Ipsum dolor sit amet
|
||||
EOF
|
||||
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id="dummy"
|
||||
|
||||
test "$(cat $final_path/index.html)" == "Lorem Ipsum dolor sit amet"
|
||||
}
|
||||
|
|
|
@ -34,10 +34,10 @@ trap cleanup EXIT SIGINT
|
|||
# Dummy http server, to serve archives for ynh_setup_source
|
||||
HTTPSERVER_DIR=$(mktemp -d)
|
||||
HTTPSERVER_PORT=1312
|
||||
pushd "$HTTPSERVER_DIR"
|
||||
pushd "$HTTPSERVER_DIR" >/dev/null
|
||||
python -m SimpleHTTPServer $HTTPSERVER_PORT &>/dev/null &
|
||||
HTTPSERVER="$!"
|
||||
popd
|
||||
popd >/dev/null
|
||||
|
||||
VAR_WWW=$(mktemp -d)/var/www
|
||||
mkdir -p $VAR_WWW
|
||||
|
@ -54,8 +54,6 @@ TESTS=$(declare -F | grep ' ynhtest_' | awk '{print $3}')
|
|||
|
||||
global_result=0
|
||||
|
||||
echo $TESTS
|
||||
|
||||
for TEST in $TESTS
|
||||
do
|
||||
log_test $TEST
|
||||
|
|
Loading…
Add table
Reference in a new issue