]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change postinst and postrm to build in cmake dir
authorBastian Dehn <hhaalo@arcor.de>
Sun, 26 Jul 2026 06:22:46 +0000 (08:22 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 26 Jul 2026 06:22:46 +0000 (08:22 +0200)
tests/CMakeLists.txt
tests/postinst.bats
tests/postrm.bats

index 0f3f08a700d78c530c4dd3ef8c6312f05db95fd2..afe0b531a44ad7cb1f62e65e42fba56db5e76181 100644 (file)
@@ -52,8 +52,8 @@ add_custom_command(TARGET runningtests
                ${CMAKE_BINARY_DIR}/coverage.info)
 add_custom_command(TARGET runningtests
        POST_BUILD
-       COMMAND ./postinst.bats
-       COMMAND ./postrm.bats
+       COMMAND BUILDDIR=${CMAKE_CURRENT_BINARY_DIR} ./postinst.bats
+       COMMAND BUILDDIR=${CMAKE_CURRENT_BINARY_DIR} ./postrm.bats
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
 
 if(CPPCHECK_VERSION VERSION_GREATER 2.10)
index e2e032d244c73bc31c2f6b863e273745e2e018b1..18c0dc92c389f4e879f693dcac75a9a69ca36b61 100755 (executable)
@@ -3,44 +3,46 @@
 setup() {
        bats_load_library bats-support
        bats_load_library bats-assert
-       mkdir --parents ../build
-       touch ../build/dllpostinst.conf
+       export BUILDDIR=${BUILDDIR:="../build"}
+       mkdir --parents "$BUILDDIR"
+       touch "$BUILDDIR/dllpostinst.conf"
 }
 
 teardown() {
-       rm -rf ../build/dllpostinst.conf
+       rm -rf "$BUILDDIR/dllpostinst.conf"
+       unset BUILDDIR
        unset DLLCONFIG
 }
 
 @test "ignore file does not exists" {
-       export DLLCONFIG="../build/dll-not-exists.conf"
+       export DLLCONFIG="$BUILDDIR/dll-not-exists.conf"
 
        run ../src/debian/postinst
 
        assert_success
-       assert_output "WARNING: ../build/dll-not-exists.conf does not exist"
+       assert_output "WARNING: $BUILDDIR/dll-not-exists.conf does not exist"
 }
 
 @test "add entry kds_s2000w_net dll.conf" {
-       export DLLCONFIG="../build/dllpostinst.conf"
+       export DLLCONFIG="$BUILDDIR/dllpostinst.conf"
 
        run ../src/debian/postinst
 
        assert_success
-       assert_line --index 0 "found ../build/dllpostinst.conf"
-       assert_line --index 1 "add kds_s2000w_net to ../build/dllpostinst.conf"
-       assert_equal "$(cat ../build/dllpostinst.conf)" "kds_s2000w_net"
-       assert_equal "$(cat ../build/dllpostinst.conf | wc --lines)" "1"
+       assert_line --index 0 "found $BUILDDIR/dllpostinst.conf"
+       assert_line --index 1 "add kds_s2000w_net to $BUILDDIR/dllpostinst.conf"
+       assert_equal "$(cat $BUILDDIR/dllpostinst.conf)" "kds_s2000w_net"
+       assert_equal "$(cat $BUILDDIR/dllpostinst.conf | wc --lines)" "1"
 }
 
 @test "entry exists in dll.conf do nothing" {
-       export DLLCONFIG="../build/dllpostinst.conf"
+       export DLLCONFIG="$BUILDDIR/dllpostinst.conf"
 
        run ../src/debian/postinst
        run ../src/debian/postinst
 
        assert_success
-       assert_output "found ../build/dllpostinst.conf"
-       assert_equal "$(cat ../build/dllpostinst.conf)" "kds_s2000w_net"
-       assert_equal "$(cat ../build/dllpostinst.conf | wc --lines)" "1"
+       assert_output "found $BUILDDIR/dllpostinst.conf"
+       assert_equal "$(cat $BUILDDIR/dllpostinst.conf)" "kds_s2000w_net"
+       assert_equal "$(cat $BUILDDIR/dllpostinst.conf | wc --lines)" "1"
 }
\ No newline at end of file
index 53dbb559715b5372449401efaa71a0290c3d93e9..67ee6c423f25d3e2e5d43bb758e150f9793d240e 100755 (executable)
@@ -3,17 +3,19 @@
 setup() {
        bats_load_library bats-support
        bats_load_library bats-assert
-       mkdir --parents ../build
-       echo kds_s2000w_net > ../build/dllpostrm.conf
+       export BUILDDIR=${BUILDDIR:="../build"}
+       mkdir --parents $BUILDDIR
+       echo kds_s2000w_net > $BUILDDIR/dllpostrm.conf
 }
 
 teardown() {
-       rm -rf ../build/dllpostrm.conf
+       rm -rf $BUILDDIR/dllpostrm.conf
+       unset BUILDDIR
        unset DLLCONFIG
 }
 
 @test "ignore file does not exist" {
-       export DLLCONFIG="../build/dll-not-exists.conf"
+       export DLLCONFIG="$BUILDDIR/dll-not-exists.conf"
 
        run ../src/debian/postrm
 
@@ -22,47 +24,47 @@ teardown() {
 }
 
 @test "delete one entry kds_s2000w_net from dll.conf {
-       export DLLCONFIG="../build/dllpostrm.conf"
+       export DLLCONFIG="$BUILDDIR/dllpostrm.conf"
 
        run ../src/debian/postrm
 
        assert_success
-       assert_line --index 0 "found ../build/dllpostrm.conf"
-       assert_line --index 1 "remove kds_s2000w_net from ../build/dllpostrm.conf"
-       assert_equal "$(cat ../build/dllpostrm.conf)" ""
-       assert_equal "$(cat ../build/dllpostrm.conf | wc --lines)" "0"
+       assert_line --index 0 "found $BUILDDIR/dllpostrm.conf"
+       assert_line --index 1 "remove kds_s2000w_net from $BUILDDIR/dllpostrm.conf"
+       assert_equal "$(cat $BUILDDIR/dllpostrm.conf)" ""
+       assert_equal "$(cat $BUILDDIR/dllpostrm.conf | wc --lines)" "0"
 }
 
 @test "delete multiple entry kds_s2000w_net from dll.conf {
-       echo kds_s2000w_net >> ../build/dllpostrm.conf
-       echo kds_s2000w_net >> ../build/dllpostrm.conf
-       echo kds_s2000w_net >> ../build/dllpostrm.conf
-       export DLLCONFIG="../build/dllpostrm.conf"
+       echo kds_s2000w_net >> $BUILDDIR/dllpostrm.conf
+       echo kds_s2000w_net >> $BUILDDIR/dllpostrm.conf
+       echo kds_s2000w_net >> $BUILDDIR/dllpostrm.conf
+       export DLLCONFIG="$BUILDDIR/dllpostrm.conf"
 
        run ../src/debian/postrm
 
-       assert_line --index 0 "found ../build/dllpostrm.conf"
-       assert_line --index 1 "remove kds_s2000w_net from ../build/dllpostrm.conf"
-       assert_equal "$(cat ../build/dllpostrm.conf)" ""
-       assert_equal "$(cat ../build/dllpostrm.conf | wc --lines)" "0"
+       assert_line --index 0 "found $BUILDDIR/dllpostrm.conf"
+       assert_line --index 1 "remove kds_s2000w_net from $BUILDDIR/dllpostrm.conf"
+       assert_equal "$(cat $BUILDDIR/dllpostrm.conf)" ""
+       assert_equal "$(cat $BUILDDIR/dllpostrm.conf | wc --lines)" "0"
 
        run ../src/debian/postrm
 
        assert_success
-       assert_line --index 0 "found ../build/dllpostrm.conf"
-       assert_equal "$(cat ../build/dllpostrm.conf)" ""
-       assert_equal "$(cat ../build/dllpostrm.conf | wc --lines)" "0"
+       assert_line --index 0 "found $BUILDDIR/dllpostrm.conf"
+       assert_equal "$(cat $BUILDDIR/dllpostrm.conf)" ""
+       assert_equal "$(cat $BUILDDIR/dllpostrm.conf | wc --lines)" "0"
 }
 
 @test "do nothing entry kds_s2000w_net not exists from dll.conf {
-       rm -rf ../build/dllpostrm.conf
-       touch ../build/dllpostrm.conf
-       export DLLCONFIG="../build/dllpostrm.conf"
+       rm -rf $BUILDDIR/dllpostrm.conf
+       touch $BUILDDIR/dllpostrm.conf
+       export DLLCONFIG="$BUILDDIR/dllpostrm.conf"
 
        run ../src/debian/postrm
 
        assert_success
-       assert_output "found ../build/dllpostrm.conf"
-       assert_equal "$(cat ../build/dllpostrm.conf)" ""
-       assert_equal "$(cat ../build/dllpostrm.conf | wc --lines)" "0"
+       assert_output "found $BUILDDIR/dllpostrm.conf"
+       assert_equal "$(cat $BUILDDIR/dllpostrm.conf)" ""
+       assert_equal "$(cat $BUILDDIR/dllpostrm.conf | wc --lines)" "0"
 }
\ No newline at end of file