2016-12-16 09:07:29 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
from __future__ import print_function
|
2017-01-03 09:10:49 +01:00
|
|
|
import optparse
|
2016-12-16 09:07:29 +01:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
try:
|
|
|
|
# We don't actually need typing, but it's a good guard for being
|
|
|
|
# outside a Zulip virtualenv.
|
|
|
|
from typing import Iterable
|
|
|
|
import requests
|
|
|
|
except ImportError as e:
|
|
|
|
print("ImportError: {}".format(e))
|
|
|
|
print("You need to run the Zulip tests inside a Zulip dev environment.")
|
|
|
|
print("If you are using Vagrant, you can `vagrant ssh` to enter the Vagrant guest.")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2017-01-03 09:10:49 +01:00
|
|
|
parser = optparse.OptionParser()
|
|
|
|
parser.add_option('--force', default=False,
|
|
|
|
action="store_true",
|
|
|
|
help='Run tests despite possible problems.')
|
|
|
|
(options, args) = parser.parse_args()
|
2016-12-16 09:07:29 +01:00
|
|
|
|
2017-01-25 18:52:35 +01:00
|
|
|
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
sys.path.insert(0, os.path.dirname(TOOLS_DIR))
|
2016-12-16 09:07:29 +01:00
|
|
|
|
2017-01-25 18:52:35 +01:00
|
|
|
from tools.lib.test_server import test_server_running
|
2016-12-16 09:07:29 +01:00
|
|
|
|
|
|
|
subprocess.check_call(['mkdir', '-p', 'var/help-documentation'])
|
|
|
|
|
|
|
|
LOG_FILE = 'var/help-documentation/server.log'
|
2017-01-25 18:52:35 +01:00
|
|
|
external_host = "localhost:9981"
|
2016-12-16 09:07:29 +01:00
|
|
|
|
2017-01-25 18:52:35 +01:00
|
|
|
with test_server_running(options.force, external_host, log_file=LOG_FILE, dots=True, use_db=False):
|
2016-12-16 09:07:29 +01:00
|
|
|
ret = subprocess.call(('scrapy', 'crawl_with_status', 'help_documentation_crawler'),
|
|
|
|
cwd='tools/documentation_crawler')
|
|
|
|
|
|
|
|
if ret != 0:
|
|
|
|
print("\033[0;91m")
|
|
|
|
print("Failed")
|
|
|
|
print("\033[0m")
|
|
|
|
else:
|
|
|
|
print("\033[0;92m")
|
|
|
|
print("Passed!")
|
|
|
|
print("\033[0m")
|
|
|
|
|
|
|
|
|
|
|
|
sys.exit(ret)
|