[Asterisk-code-review] Add self test script. (testsuite[13.21])

George Joseph asteriskteam at digium.com
Fri May 11 09:01:04 CDT 2018


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/8962 )

Change subject: Add self_test script.
......................................................................

Add self_test script.

This script will be used by jenkins to run python unit tests.  The
primary goal is to avoid having jenkins depend on location of the unit
tests.  For now it includes specific tests that jenkins has been running
from lib/python/asterisk, plus all tests in
lib/python/asterisk/self_test.  Anything in the self_test folder is
expected to pass under both python2 and python3.

Change-Id: Ie6fe082b1a2d46b229bab27abed97e85ad6c4f13
---
A self_test
1 file changed, 43 insertions(+), 0 deletions(-)

Approvals:
  Jenkins2: Verified
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/self_test b/self_test
new file mode 100755
index 0000000..240bfcb
--- /dev/null
+++ b/self_test
@@ -0,0 +1,43 @@
+#!/usr/bin/sh -e
+
+PYTHON=""
+PYTHON2=$(which python2 2>/dev/null || true)
+PYTHON3=$(which python3 2>/dev/null || true)
+
+if test -z "$PYTHON2$PYTHON3"; then
+	PYTHON=$(which python 2>/dev/null || true)
+
+	if test -z "$PYTHON"; then
+		echo "No python binary found, cannot run any tests"
+		exit 1
+	fi
+fi
+
+run_test() {
+	# Arguments: test_name python_name python_bin
+	if test -n "$3"; then
+		echo " ==> Executing $1 ($2)"
+		$3 lib/python/asterisk/self_test/${1}.py
+	fi
+}
+
+ALL_TESTS=$(find lib/python/asterisk/self_test -name 'test_*.py' -exec basename '{}' .py \;)
+for i in $ALL_TESTS; do
+	run_test $i python $PYTHON
+	run_test $i python2 $PYTHON2
+	run_test $i python3 $PYTHON3
+done
+
+# Temporary code for running unit tests that are not compatible with python3
+run_legacy_test() {
+	# Arguments: test_name python_name python_bin
+	if test -n "$3"; then
+		echo " ==> Executing $1 ($2)"
+		$3 lib/python/asterisk/${1}.py
+	fi
+}
+
+for i in buildoptions channel_test_condition sippversion; do
+	run_legacy_test $i python $PYTHON
+	run_legacy_test $i python2 $PYTHON2
+done

-- 
To view, visit https://gerrit.asterisk.org/8962
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 13.21
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie6fe082b1a2d46b229bab27abed97e85ad6c4f13
Gerrit-Change-Number: 8962
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180511/8e1b1b74/attachment-0001.html>


More information about the asterisk-code-review mailing list