Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
tests: lua: sample: Extend the test to be more like sample.ucl from FreeBSD ports
Emmanuel Vadot committed 5 years ago
commit 720756c86ec3f64eb34663396bbe03acc523a35e
parent 6ce321f
1 file changed +19 -5
modified tests/frontend/lua.sh
@@ -534,15 +534,22 @@ EOF

script_sample_not_exists_body() {
	echo "sample text" > a.sample
-
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"
	cat << EOF >> test.ucl
files: {
	${TMPDIR}/a.sample: ""
}
lua_scripts: {
  post-install: [ <<EOS
-
  if pkg.filecmp("${TMPDIR}/a.sample", "${TMPDIR}/a") == 2 then
-
     pkg.copy("${TMPDIR}/a.sample", "${TMPDIR}/a")
+
  args = {"a.sample"}
+
  sample_file = pkg.prefixed_path(args[1])
+
  if args[2] == nil then
+
    target_file = string.gsub(sample_file,'%.sample$', "")
+
  else
+
    target_file = pkg.prefixed_path(args[2])
+
  end
+
  if not pkg.stat(target_file) then
+
    pkg.copy(sample_file, target_file)
  end
EOS
, ]
@@ -580,8 +587,15 @@ files: {
}
lua_scripts: {
  post-install: [ <<EOS
-
  if pkg.filecmp("${TMPDIR}/a.sample", "${TMPDIR}/a") == 2 then
-
     pkg.copy("${TMPDIR}/a.sample", "${TMPDIR}/a")
+
  args = {"a.sample"}
+
  sample_file = pkg.prefixed_path(args[1])
+
  if args[2] == nil then
+
    target_file = string.gsub(sample_file,'%.sample$', "")
+
  else
+
    target_file = pkg.prefixed_path(args[2])
+
  end
+
  if not pkg.stat(target_file) then
+
    pkg.copy(sample_file, target_file)
  end
EOS
, ]