Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
tests: lua: sample: Add a tests when we sample a symlink
Emmanuel Vadot committed 5 years ago
commit dd780d8c7260e2738726ce0eeb4b465d86b09dfd
parent 6752ac1
1 file changed +50 -0
modified tests/frontend/lua.sh
@@ -15,6 +15,7 @@ tests_init \
	script_copy \
	script_copy_symlink \
	script_sample_not_exists \
+
	script_sample_not_exists_symlink \
	script_sample_not_exists_two_files \
	script_sample_exists \
	script_stat \
@@ -579,6 +580,55 @@ EOF
		cmp -s ${TMPDIR}/target${TMPDIR}/a.sample ${TMPDIR}/target${TMPDIR}/a
}

+
script_sample_not_exists_symlink_body() {
+
	echo "sample text" > a
+
	ln -s a b.sample
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"
+
	cat << EOF >> test.ucl
+
files: {
+
	${TMPDIR}/a: ""
+
	${TMPDIR}/b.sample: ""
+
}
+
lua_scripts: {
+
  post-install: [ <<EOS
+
  args = {"b.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
+
, ]
+
}
+
EOF
+

+
	atf_check \
+
		-o empty \
+
		-e empty \
+
		-s exit:0 \
+
		pkg create -M test.ucl
+

+
	mkdir ${TMPDIR}/target
+
	atf_check \
+
		-o empty \
+
		-e empty \
+
		-s exit:0 \
+
		pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.txz
+

+
	atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/a
+
	atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/b.sample
+
	atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/b
+
	atf_check \
+
		-o empty \
+
		-e empty \
+
		-s exit:0 \
+
		cmp -s ${TMPDIR}/target${TMPDIR}/b.sample ${TMPDIR}/target${TMPDIR}/b
+
}
+

script_sample_not_exists_two_files_body() {
	echo "sample text" > a
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"