Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] common/tests: create
@ 2021-03-13 21:23 Chocimier
  2022-05-08  2:12 ` github-actions
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Chocimier @ 2021-03-13 21:23 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 311 bytes --]

There is a new pull request by Chocimier against master on the void-packages repository

https://github.com/Chocimier/void-packages-org tests
https://github.com/void-linux/void-packages/pull/29448

common/tests: create


A patch file from https://github.com/void-linux/void-packages/pull/29448.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-tests-29448.patch --]
[-- Type: text/x-diff, Size: 7344 bytes --]

From 70c106127b8debfbf2a65e1b7b371af205b7fd75 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <chocimier@tlen.pl>
Date: Sat, 13 Mar 2021 22:16:17 +0100
Subject: [PATCH] common/tests: create

---
 common/tests/00-target-pkg.bats       |  7 +++
 common/tests/10-jobs_number.bats      | 45 +++++++++++++++++
 common/tests/10-options-comptype.bats | 71 +++++++++++++++++++++++++++
 common/tests/all.sh                   | 11 +++++
 common/tests/lib/testfuncs.bash       | 24 +++++++++
 common/tests/templates/jobcounter     | 26 ++++++++++
 common/tests/templates/pkg            |  9 ++++
 7 files changed, 193 insertions(+)
 create mode 100644 common/tests/00-target-pkg.bats
 create mode 100644 common/tests/10-jobs_number.bats
 create mode 100644 common/tests/10-options-comptype.bats
 create mode 100755 common/tests/all.sh
 create mode 100644 common/tests/lib/testfuncs.bash
 create mode 100644 common/tests/templates/jobcounter
 create mode 100644 common/tests/templates/pkg

diff --git a/common/tests/00-target-pkg.bats b/common/tests/00-target-pkg.bats
new file mode 100644
index 000000000000..02428e41d0c1
--- /dev/null
+++ b/common/tests/00-target-pkg.bats
@@ -0,0 +1,7 @@
+@test "Build simple pkg" {
+	load lib/testfuncs
+	prepare_pkg_test
+	./xbps-src -c "${tmprepo}" -r "${tmprepo}" pkg xbps-src-test-pkg
+	test -f "${pkgfile}"
+	cleanup_pkg_test
+}
diff --git a/common/tests/10-jobs_number.bats b/common/tests/10-jobs_number.bats
new file mode 100644
index 000000000000..d92a124d0a10
--- /dev/null
+++ b/common/tests/10-jobs_number.bats
@@ -0,0 +1,45 @@
+@test "by default, one job" {
+	load lib/testfuncs
+	prepare_pkg_test jobcounter
+	./xbps-src -c "${tmprepo}" -r "${tmprepo}" pkg xbps-src-test-jobcounter
+	test -f "${pkgfile}"
+	jobs=$(tar xOf ${pkgfile} ./etc/jobs)
+	echo "$jobs"
+	test 1 = "$jobs"
+	cleanup_pkg_test
+}
+
+@test "-j 11" {
+	load lib/testfuncs
+	prepare_pkg_test jobcounter
+	./xbps-src -c "${tmprepo}" -r "${tmprepo}" -j 11 pkg xbps-src-test-jobcounter
+	test -f "${pkgfile}"
+	jobs=$(tar xOf ${pkgfile} ./etc/jobs)
+	echo "$jobs"
+	test 11 = "$jobs"
+	cleanup_pkg_test
+}
+
+@test "XBPS_MAKEJOBS=6" {
+	load lib/testfuncs
+	prepare_pkg_test jobcounter
+	echo XBPS_MAKEJOBS=6 > "${tmpconf}"
+	./xbps-src -c "${tmprepo}" -r "${tmprepo}" pkg xbps-src-test-jobcounter
+	test -f "${pkgfile}"
+	jobs=$(tar xOf ${pkgfile} ./etc/jobs)
+	echo "$jobs"
+	test 6 = "$jobs"
+	cleanup_pkg_test
+}
+
+@test "-j 2 XBPS_MAKEJOBS=5" {
+	load lib/testfuncs
+	prepare_pkg_test jobcounter
+	echo XBPS_MAKEJOBS=5 > "${tmpconf}"
+	./xbps-src -c "${tmprepo}" -r "${tmprepo}" -j 2 pkg xbps-src-test-jobcounter
+	test -f "${pkgfile}"
+	jobs=$(tar xOf ${pkgfile} ./etc/jobs)
+	echo "$jobs"
+	test 2 = "$jobs"
+	cleanup_pkg_test
+}
diff --git a/common/tests/10-options-comptype.bats b/common/tests/10-options-comptype.bats
new file mode 100644
index 000000000000..f403bbd5d2c8
--- /dev/null
+++ b/common/tests/10-options-comptype.bats
@@ -0,0 +1,71 @@
+@test "XBPS_PKG_COMPTYPE=none" {
+	load lib/testfuncs
+	prepare_pkg_test
+	echo XBPS_PKG_COMPTYPE=none > "${tmpconf}"
+	./xbps-src -c "${tmprepo}" -r "${tmprepo}" pkg xbps-src-test-pkg
+	test -f "${pkgfile}"
+	mime=$(file -b --mime-type "${pkgfile}")
+	echo "$mime"
+	test application/x-tar = "$mime"
+	cleanup_pkg_test
+}
+
+@test "XBPS_PKG_COMPTYPE=gzip" {
+	load lib/testfuncs
+	prepare_pkg_test
+	echo XBPS_PKG_COMPTYPE=gzip > "${tmpconf}"
+	./xbps-src -c "${tmprepo}" -r "${tmprepo}" pkg xbps-src-test-pkg
+	test -f "${pkgfile}"
+	mime=$(file -b --mime-type "${pkgfile}")
+	echo "$mime"
+	test application/gzip = "$mime"
+	cleanup_pkg_test
+}
+
+@test "XBPS_PKG_COMPTYPE=bzip2" {
+	load lib/testfuncs
+	prepare_pkg_test
+	echo XBPS_PKG_COMPTYPE=bzip2 > "${tmpconf}"
+	./xbps-src -c "${tmprepo}" -r "${tmprepo}" pkg xbps-src-test-pkg
+	test -f "${pkgfile}"
+	mime=$(file -b --mime-type "${pkgfile}")
+	echo "$mime"
+	test application/x-bzip2 = "$mime"
+	cleanup_pkg_test
+}
+
+@test "XBPS_PKG_COMPTYPE=xz" {
+	load lib/testfuncs
+	prepare_pkg_test
+	echo XBPS_PKG_COMPTYPE=xz > "${tmpconf}"
+	./xbps-src -c "${tmprepo}" -r "${tmprepo}" pkg xbps-src-test-pkg
+	test -f "${pkgfile}"
+	mime=$(file -b --mime-type "${pkgfile}")
+	echo "$mime"
+	test application/x-xz = "$mime"
+	cleanup_pkg_test
+}
+
+@test "XBPS_PKG_COMPTYPE=lz4" {
+	load lib/testfuncs
+	prepare_pkg_test
+	echo XBPS_PKG_COMPTYPE=lz4 > "${tmpconf}"
+	./xbps-src -c "${tmprepo}" -r "${tmprepo}" pkg xbps-src-test-pkg
+	test -f "${pkgfile}"
+	mime=$(file -b --mime-type "${pkgfile}")
+	echo "$mime"
+	test application/x-lz4 = "$mime"
+	cleanup_pkg_test
+}
+
+@test "XBPS_PKG_COMPTYPE=zstd" {
+	load lib/testfuncs
+	prepare_pkg_test
+	echo XBPS_PKG_COMPTYPE=zstd > "${tmpconf}"
+	./xbps-src -c "${tmprepo}" -r "${tmprepo}" pkg xbps-src-test-pkg
+	test -f "${pkgfile}"
+	mime=$(file -b --mime-type "${pkgfile}")
+	echo "$mime"
+	test application/zstd = "$mime"
+	cleanup_pkg_test
+}
diff --git a/common/tests/all.sh b/common/tests/all.sh
new file mode 100755
index 000000000000..fafdde8171a0
--- /dev/null
+++ b/common/tests/all.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+if ! command -v bats > /dev/null; then
+	echo Missing 'bats' command
+	exit 1
+fi
+
+for i in "$(dirname "$0")"/*.bats; do
+	echo $i
+	bats "$i"
+done
diff --git a/common/tests/lib/testfuncs.bash b/common/tests/lib/testfuncs.bash
new file mode 100644
index 000000000000..e7ba6a541599
--- /dev/null
+++ b/common/tests/lib/testfuncs.bash
@@ -0,0 +1,24 @@
+distdir="${BATS_TEST_DIRNAME}/../.."
+template=
+tmprepodir=
+tmprepo=
+tmpconf=
+
+prepare_pkg_test() {
+	template=${1:-pkg}
+	cd "${distdir}"
+	tmprepodir="$(mktemp -d -p ${PWD}/hostdir/binpkgs)"
+	tmprepo="$(basename ${tmprepodir})"
+	tmpconf="etc/conf.${tmprepo}"
+	pkgfile="${tmprepodir}/xbps-src-test-${template}-1_1.$(xbps-uhelper arch).xbps"
+	rm -fr srcpkgs/xbps-src-test-${template}
+	mkdir srcpkgs/xbps-src-test-${template}
+	cp "${BATS_TEST_DIRNAME}/templates/${template}" srcpkgs/xbps-src-test-${template}/template
+	echo XBPS_SUCMD=true > "${tmpconf}"
+}
+
+cleanup_pkg_test() {
+	rm -r srcpkgs/xbps-src-test-${template}
+	rm -r "${tmprepodir}"
+	rm "etc/conf.${tmprepo}"
+}
diff --git a/common/tests/templates/jobcounter b/common/tests/templates/jobcounter
new file mode 100644
index 000000000000..77a56bdd751e
--- /dev/null
+++ b/common/tests/templates/jobcounter
@@ -0,0 +1,26 @@
+# Template file for 'xbps-src-test-jobcounter'
+pkgname=xbps-src-test-jobcounter
+version=1
+revision=1
+build_style=gnu-makefile
+make_cmd="./make"
+make_use_env=yes
+short_desc="Dummy package"
+license="BSD-2-Clause"
+maintainer="Orphaned <orphan@voidlinux.org>"
+homepage="http://voidlinux.org"
+
+pre_build() {
+	mkdir -p ${DESTDIR}/etc
+	cat > ./make << EOF
+	#!/usr/bin/env bash
+	echo x "\$@"
+	while getopts "j:" opt; do
+		case "\$opt" in
+			j) echo \$OPTARG > ${DESTDIR}/etc/jobs; exit 0
+		esac
+	done
+EOF
+	cat make
+	chmod +x ./make
+}
diff --git a/common/tests/templates/pkg b/common/tests/templates/pkg
new file mode 100644
index 000000000000..68333f6fa80e
--- /dev/null
+++ b/common/tests/templates/pkg
@@ -0,0 +1,9 @@
+# Template file for 'xbps-src-test-pkg'
+pkgname=xbps-src-test-pkg
+version=1
+revision=1
+build_style=meta
+short_desc="Dummy package"
+license="BSD-2-Clause"
+maintainer="Orphaned <orphan@voidlinux.org>"
+homepage="http://voidlinux.org"

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-16  1:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-13 21:23 [PR PATCH] common/tests: create Chocimier
2022-05-08  2:12 ` github-actions
2022-08-09  2:13 ` github-actions
2022-08-24  2:14 ` [PR PATCH] [Closed]: " github-actions
2023-01-30 18:44 ` [PR PATCH] [Updated] " Chocimier
2023-05-02  1:52 ` github-actions
2023-05-16  1:54 ` [PR PATCH] [Closed]: " github-actions

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).