Infrastructure to run tests under both python 2 and 3
This commit is contained in:
parent
df1131b1dc
commit
716c8bd02c
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.1 (the "License"); you may not use this file except in
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ COVER:=false
|
|||
WITH_BROKER_TEST_COMMANDS:=rabbit_test_runner:run_in_broker(\"$(PACKAGE_DIR)/test/ebin\",\"$(FILTER)\")
|
||||
WITH_BROKER_TEST_CONFIG:=$(PACKAGE_DIR)/etc/rabbit-test
|
||||
STANDALONE_TEST_COMMANDS:=rabbit_test_runner:run_multi(\"$(UMBRELLA_BASE_DIR)/rabbitmq-server\",\"$(PACKAGE_DIR)/test/ebin\",\"$(FILTER)\",$(COVER),\"/tmp/rabbitmq-multi-node/plugins\")
|
||||
WITH_BROKER_TEST_SCRIPTS:=$(PACKAGE_DIR)/test/src/rabbitmqadmin-test.py
|
||||
WITH_BROKER_TEST_SCRIPTS:=$(PACKAGE_DIR)/test/src/rabbitmqadmin-test-wrapper.sh
|
||||
|
||||
CONSTRUCT_APP_PREREQS:=$(shell find $(PACKAGE_DIR)/priv -type f) $(PACKAGE_DIR)/bin/rabbitmqadmin
|
||||
define construct_app_commands
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh -e
|
||||
TWO=$(python2 -c 'import sys;print(sys.version_info[0])')
|
||||
THREE=$(python3 -c 'import sys;print(sys.version_info[0])')
|
||||
|
||||
if [ $TWO != 2 ] ; then
|
||||
echo Python 2 not found!
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $THREE != 3 ] ; then
|
||||
echo Python 3 not found!
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ----------------------
|
||||
echo Testing under Python 2
|
||||
echo ----------------------
|
||||
|
||||
# TODO make this pass!
|
||||
#python2 $(dirname $0)/rabbitmqadmin-test.py
|
||||
|
||||
echo ----------------------
|
||||
echo Testing under Python 3
|
||||
echo ----------------------
|
||||
|
||||
python3 $(dirname $0)/rabbitmqadmin-test.py
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
|
||||
import unittest
|
||||
import os
|
||||
|
|
@ -212,21 +212,24 @@ tracing: False
|
|||
args.extend(args0)
|
||||
self.assertEqual(expected, [l.split('\t') for l in self.admin(args)[0].splitlines()])
|
||||
|
||||
def admin(self, args, stdin=None):
|
||||
return run('../../../bin/rabbitmqadmin', args, stdin)
|
||||
def admin(self, args0, stdin=None):
|
||||
args = ['python{0}'.format(sys.version_info[0]),
|
||||
norm('../../../bin/rabbitmqadmin')]
|
||||
args.extend(args0)
|
||||
return run(args, stdin)
|
||||
|
||||
def ctl(self, args0, stdin=None):
|
||||
args = ['-n', 'rabbit-test']
|
||||
args = [norm('../../../../rabbitmq-server/scripts/rabbitmqctl'), '-n', 'rabbit-test']
|
||||
args.extend(args0)
|
||||
(stdout, ret) = run('../../../../rabbitmq-server/scripts/rabbitmqctl', args, stdin)
|
||||
(stdout, ret) = run(args, stdin)
|
||||
if ret != 0:
|
||||
self.fail(stdout)
|
||||
|
||||
def run(cmd, args, stdin):
|
||||
path = os.path.normpath(os.path.join(os.getcwd(), sys.argv[0], cmd))
|
||||
cmdline = [path]
|
||||
cmdline.extend(args)
|
||||
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
def norm(cmd):
|
||||
return os.path.normpath(os.path.join(os.getcwd(), sys.argv[0], cmd))
|
||||
|
||||
def run(args, stdin):
|
||||
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(stdout, stderr) = proc.communicate(stdin)
|
||||
returncode = proc.returncode
|
||||
res = stdout.decode('utf-8') + stderr.decode('utf-8')
|
||||
|
|
|
|||
Loading…
Reference in New Issue