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

Corey Farrell asteriskteam at digium.com
Thu May 10 11:05:03 CDT 2018


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/8964


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(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/64/8964/1

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/8964
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 15.4
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie6fe082b1a2d46b229bab27abed97e85ad6c4f13
Gerrit-Change-Number: 8964
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180510/9b65c4d3/attachment.html>


More information about the asterisk-code-review mailing list