mirror of https://github.com/zulip/zulip.git
tools: Fix running full-stack tests from tools/ directory.
Previously these tests required you to run them with the root of the Zulip repository as the current working directory, just due to sloppiness. We clean this up, while also making the path handling more consistent and involving less fragile code. Fixes #4169.
This commit is contained in:
parent
bd7d9da668
commit
02d931a53e
|
@ -14,8 +14,10 @@ import glob
|
||||||
# on how to use remote debugging
|
# on how to use remote debugging
|
||||||
#
|
#
|
||||||
|
|
||||||
|
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
os.environ["CASPER_TESTS"] = "1"
|
os.environ["CASPER_TESTS"] = "1"
|
||||||
os.environ["PHANTOMJS_EXECUTABLE"] = os.path.join(os.path.dirname(__file__), "../node_modules/.bin/phantomjs")
|
os.environ["PHANTOMJS_EXECUTABLE"] = os.path.join(ZULIP_PATH, "node_modules/.bin/phantomjs")
|
||||||
os.environ["http_proxy"] = ""
|
os.environ["http_proxy"] = ""
|
||||||
os.environ["https_proxy"] = ""
|
os.environ["https_proxy"] = ""
|
||||||
|
|
||||||
|
@ -39,8 +41,7 @@ parser.add_option('--remote-debug',
|
||||||
default=False)
|
default=False)
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
sys.path.insert(0, ZULIP_PATH)
|
||||||
sys.path.insert(0, os.path.dirname(TOOLS_DIR))
|
|
||||||
|
|
||||||
# check for the venv
|
# check for the venv
|
||||||
from tools.lib import sanity_check
|
from tools.lib import sanity_check
|
||||||
|
@ -58,7 +59,7 @@ if not options.force:
|
||||||
print('If you really know what you are doing, use --force to run anyway.')
|
print('If you really know what you are doing, use --force to run anyway.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
os.chdir(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
|
os.chdir(ZULIP_PATH)
|
||||||
|
|
||||||
subprocess.check_call('tools/setup/generate-test-credentials')
|
subprocess.check_call('tools/setup/generate-test-credentials')
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ LOG_FILE = 'var/casper/server.log'
|
||||||
|
|
||||||
def run_tests(files, external_host):
|
def run_tests(files, external_host):
|
||||||
# type: (Iterable[str], str) -> None
|
# type: (Iterable[str], str) -> None
|
||||||
test_dir = os.path.join(os.path.dirname(__file__), '../frontend_tests/casper_tests')
|
test_dir = os.path.join(ZULIP_PATH, 'frontend_tests/casper_tests')
|
||||||
test_files = []
|
test_files = []
|
||||||
for file in files:
|
for file in files:
|
||||||
for file_name in os.listdir(test_dir):
|
for file_name in os.listdir(test_dir):
|
||||||
|
|
|
@ -9,9 +9,9 @@ from lib import sanity_check
|
||||||
sanity_check.check_venv(__file__)
|
sanity_check.check_venv(__file__)
|
||||||
|
|
||||||
import django
|
import django
|
||||||
TOOLS_DIR = os.path.dirname(__file__)
|
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
ROOT_DIR = os.path.dirname(TOOLS_DIR)
|
sys.path.insert(0, ZULIP_PATH)
|
||||||
sys.path.insert(0, ROOT_DIR)
|
os.chdir(ZULIP_PATH)
|
||||||
|
|
||||||
from zulip import Client
|
from zulip import Client
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import subprocess
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
# check for the venv
|
# check for the venv
|
||||||
from lib import sanity_check
|
from lib import sanity_check
|
||||||
|
@ -21,9 +22,8 @@ parser.add_option('--force', default=False,
|
||||||
help='Run tests despite possible problems.')
|
help='Run tests despite possible problems.')
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
os.chdir(ZULIP_PATH)
|
||||||
sys.path.insert(0, os.path.dirname(TOOLS_DIR))
|
sys.path.insert(0, ZULIP_PATH)
|
||||||
|
|
||||||
from tools.lib.test_server import test_server_running
|
from tools.lib.test_server import test_server_running
|
||||||
|
|
||||||
subprocess.check_call(['mkdir', '-p', 'var/help-documentation'])
|
subprocess.check_call(['mkdir', '-p', 'var/help-documentation'])
|
||||||
|
|
Loading…
Reference in New Issue