]> git.corax.cc Git - toolbox/commitdiff
test.sh: Prefer toolbox in same directory over globally installed one
authorMatthias Kruk <m@m10k.eu>
Sat, 7 Jan 2023 07:10:23 +0000 (16:10 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 7 Jan 2023 07:22:04 +0000 (16:22 +0900)
Because test.sh uses the environment's PATH, it ends up using whatever
toolbox is installed in the environment, instead of the toolbox that it
was shipped with.

This commit modifies the test script so that it overrides the path,
making tests use the toolbox they were distributed with. This also
removes unnecessary PATH modifications from the test specs.

13 files changed:
test.sh
test/array_spec.sh
test/include [deleted symlink]
test/ipc_spec.sh
test/is_spec.sh
test/json_spec.sh
test/log_spec.sh
test/mutex_spec.sh
test/opt_spec.sh
test/queue_spec.sh
test/sem_spec.sh
test/uipc_spec.sh
test/wmutex_spec.sh

diff --git a/test.sh b/test.sh
index 5c2f4c11c3082aff9145c618d0320775ca53c5cb..9895b63a8ca9d6f1b339f507a7670fdda54b3e48 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -85,7 +85,36 @@ main() {
        return 0
 }
 
+whereami() {
+       local scriptpath
+
+       if ! scriptpath=$(realpath "${BASH_SOURCE[0]}"); then
+               return 1
+       fi
+
+       echo "${scriptpath%/*}"
+       return 0
+}
+
+use_this_toolbox() {
+       local here
+
+       if ! here=$(whereami); then
+               return 1
+       fi
+
+       if ! export PATH="$here:$PATH"; then
+               return 1
+       fi
+
+       return 0
+}
+
 {
+       if ! use_this_toolbox; then
+               exit 1
+       fi
+
        if ! . toolbox.sh; then
                exit 1
        fi
index d6f8210b989932c8cdf9b29b361e9d2fe80ac11a..30ec14e1aaf026145343f9f3036c2af342dbc476 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # array_spec.sh - Test cases for the toolbox array module
-# Copyright (C) 2021 Matthias Kruk
+# Copyright (C) 2021-2023 Matthias Kruk
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,8 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-export PATH="$PWD/..:$PATH"
-
 if ! . toolbox.sh; then
        exit 1
 fi
diff --git a/test/include b/test/include
deleted file mode 120000 (symlink)
index f5030fe..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../include
\ No newline at end of file
index c45aa63a042392b057155cd77bdd4ccbc83fc59e..2a699d6c01f7e540237162b1efbd3dbb7fb809ca 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # ipc_spec.sh - Test cases for the toolbox ipc module
-# Copyright (C) 2021 Matthias Kruk
+# Copyright (C) 2021-2023 Matthias Kruk
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,8 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-export PATH="$PWD/..:$PATH"
-
 . toolbox.sh
 include "ipc"
 
index e23df5a67f43ca1cfd04c22b1ecac603c2b2cf8a..86ce7706d5799a21161b648904fda1eec7d73432 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # is_spec.sh - Test cases for the toolbox is module
-# Copyright (C) 2021 Matthias Kruk
+# Copyright (C) 2021-2023 Matthias Kruk
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,8 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-export PATH="$PWD/..:$PATH"
-
 . toolbox.sh
 include "is"
 
index 3a648761b85a0d864a25aadda7ded44d66de8a7b..bbe5e0d534bfb6232a3fb004ec5e481917fd3c63 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # json_spec.sh - Test cases for the toolbox json module
-# Copyright (C) 2021 Matthias Kruk
+# Copyright (C) 2021-2023 Matthias Kruk
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,8 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-export PATH="$PWD/..:$PATH"
-
 if ! . toolbox.sh; then
        exit 1
 fi
index 13868c6dc85c1ba2ac3c66b6026b8cab09bdee60..757a5c6587a34d241d715a25fc22992b9b21004a 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # log_spec.sh - Test cases for the toolbox log module
-# Copyright (C) 2021 Matthias Kruk
+# Copyright (C) 2021-2023 Matthias Kruk
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,8 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-export PATH="$PWD/..:$PATH"
-
 . toolbox.sh
 
 include "log"
index ef96d12a784ac55c1639ef56e6074d479112d778..0e4429168db067735c6720057618a533335b056d 100644 (file)
@@ -1,7 +1,5 @@
 #!/bin/bash
 
-export PATH="$PWD/..:$PATH"
-
 . toolbox.sh
 include "mutex"
 
index 81a8ab53a836e9f4800401a84025064ac7e07f92..50d8d663d1abd096c2073687e7fa3949c6fe1f39 100644 (file)
@@ -1,7 +1,5 @@
 #!/bin/bash
 
-export PATH="$PWD/..:$PATH"
-
 . toolbox.sh
 include "opt"
 
index a921348b95496bb098f8682800828b50b88f55f3..6aaab60c78db2658fe7056dabcaf5fa74a038a4f 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # queue_spec.sh - Test cases for the toolbox queue module
-# Copyright (C) 2021 Matthias Kruk
+# Copyright (C) 2021-2023 Matthias Kruk
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,8 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-export PATH="$PWD/..:$PATH"
-
 if ! . toolbox.sh; then
        exit 1
 fi
index 72d10557f262588f93cb46e84c0dd2894e39b534..f4e0a227e23ab734f94a4b9148fd97bf572c369e 100644 (file)
@@ -1,7 +1,5 @@
 #!/bin/bash
 
-export PATH="$PWD/..:$PATH"
-
 . toolbox.sh
 include "sem"
 
index 9d258066c63a1a95d36837cb61e517f03bcf8690..9f0e22dc17721cf1a77c637c0c603acd2599b57c 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # uipc_spec.sh - Test cases for the toolbox uipc module
-# Copyright (C) 2022 Matthias Kruk
+# Copyright (C) 2022-2023 Matthias Kruk
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,8 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-export PATH="$PWD/..:$PATH"
-
 . toolbox.sh
 include "uipc"
 
index ad1c5bf5e8725405e75ce989c043433b2d836a9d..61adfec84031e351b6701a99bd442f8209a21802 100644 (file)
@@ -1,7 +1,5 @@
 #!/bin/bash
 
-export PATH="$PWD/..:$PATH"
-
 . toolbox.sh
 include "wmutex"