diff --git a/tests/lib/patcher.ml b/tests/lib/patcher.ml index 8b21a4c72d2..a2a473bb3a1 100644 --- a/tests/lib/patcher.ml +++ b/tests/lib/patcher.ml @@ -82,7 +82,13 @@ let generate_patch () = Printf.eprintf "Before patch state of c:\n"; print_directory "."; flush stdout; - if Sys.command "patch -p1 -i ../output.patch" <> 0 then (Printf.eprintf "patch application failed\n%!"; exit 2); + let gpatch = + if Sys.command "sh -c \"command -v gpatch > /dev/null 2> /dev/null\"" = 0 then + "gpatch" + else + "patch" + in + if Sys.command (gpatch^" -p1 -i ../output.patch") <> 0 then (Printf.eprintf "patch application failed\n%!"; exit 2); Printf.eprintf "After patch state of c:\n"; print_directory "."; OpamSystem.chdir Filename.parent_dir_name diff --git a/tests/reftests/repository.test b/tests/reftests/repository.test index fd3595dae02..a0a9cf84b2c 100644 --- a/tests/reftests/repository.test +++ b/tests/reftests/repository.test @@ -18,7 +18,7 @@ some content ### sh hash.sh REPO foo.1 ### : Internal repository storage as archive or plain directory : ### opam switch create tarring --empty -### opam update -vv | grep '^\+' | sed-cmd diff | sed-cmd patch | 'patch-[^"]+' -> 'patch' +### opam update -vv | grep '^\+' | sed-cmd diff | sed-cmd patch | sed-cmd gpatch | '\+ gpatch ' -> '+ patch ' | 'patch-[^"]+' -> 'patch' + diff "-ruaN" "default" "default.new" (CWD=${BASEDIR}/OPAM/repo) + patch "--version" + patch "-p1" "-i" "${BASEDIR}/OPAM/log/patch" (CWD=${BASEDIR}/OPAM/repo/default) @@ -38,7 +38,7 @@ build: ["test" "-f" "baz"] ### some content ### sh hash.sh REPO foo.2 -### opam update default -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | 'patch-[^"]+' -> 'patch' +### opam update default -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | sed-cmd gpatch | '\+ gpatch ' -> '+ patch ' | 'patch-[^"]+' -> 'patch' + diff "-ruaN" "default" "default.new" (CWD=${BASEDIR}/OPAM/repo) + patch "--version" + patch "-p1" "-i" "${BASEDIR}/OPAM/log/patch" (CWD=${BASEDIR}/OPAM/repo/default) @@ -78,7 +78,7 @@ build: ["test" "-f" "baz"] ### some content ### sh hash.sh REPO foo.4 -### opam update -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | 'patch-[^"]+' -> 'patch' +### opam update -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | sed-cmd gpatch | '\+ gpatch ' -> '+ patch ' | 'patch-[^"]+' -> 'patch' + tar "xfz" "${BASEDIR}/OPAM/repo/tarred.tar.gz" "-C" "${OPAMTMP}" + diff "-ruaN" "tarred" "tarred.new" (CWD=${OPAMTMP}) + patch "--version" @@ -102,7 +102,7 @@ build: ["test" "-f" "quux"] ### some content ### sh hash.sh REPO foo.5 -### opam update -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | 'patch-[^"]+' -> 'patch' +### opam update -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | sed-cmd gpatch | '\+ gpatch ' -> '+ patch ' | 'patch-[^"]+' -> 'patch' + tar "xfz" "${BASEDIR}/OPAM/repo/tarred.tar.gz" "-C" "${OPAMTMP}" + diff "-ruaN" "tarred" "tarred.new" (CWD=${OPAMTMP}) + patch "--version"