Skip to content

Commit

Permalink
Merge branch 'master' into gh-1436
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Mar 3, 2020
2 parents d4954b0 + 520f156 commit 77a88e6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 58 deletions.
File renamed without changes.
94 changes: 40 additions & 54 deletions test/behave
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,42 @@ for d in pathlib.Path(__file__).resolve().parents:
ROOT = d
break
os.chdir(ROOT)

# because behave doesn't think it's useful to be able to load local stuff... oy...
sys.path.insert(0, os.path.abspath('test/features/steps'))

def load_json(path, default):
try:
with open(path) as f:
return json.load(f)
except:
return default
class BooleanAction(argparse.Action):
def __init__(self, option_strings, dest, nargs=None, **kwargs):
super().__init__(option_strings, dest, nargs=0, **kwargs)

def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, option_string.startswith('--no'))
parser = argparse.ArgumentParser()
parser.add_argument('--no-stop', action='store_true')
parser.add_argument('--nightly', action='store_true')
parser.add_argument('--jurism', action='store_true')
parser.add_argument('--stop', '--no-stop', dest='stop', action=BooleanAction, default=True)
parser.add_argument('--jurism', action='store_true', default=os.environ.get('CLIENT') == 'jurism')
parser.add_argument('--beta', action='store_true')
parser.add_argument('--keep', action='store_true')
parser.add_argument('--no-workers', action='store_true')
parser.add_argument('--keep', '--no-keep', dest='keep', action=BooleanAction, default=False)
parser.add_argument('--workers', '--no-workers', dest='workers', action=BooleanAction, default=True)
parser.add_argument('--this', action='store_true')

parser.add_argument('--slow', action='store_true',
default = os.environ.get('TRAVIS_BRANCH') in load_json(os.path.join(ROOT, '.slow.json'), []) or
'#slow' in os.environ.get('TRAVIS_COMMIT_MESSAGE', '') or
os.environ.get('TRAVIS_EVENT_TYPE') == 'cron'
)
parser.add_argument('--tagged', action='store_true', default=os.environ.get('TRAVIS_TAG', '') != '')
parser.add_argument('--nightly', action='store_true', default=os.environ.get('TRAVIS_EVENT_TYPE') == 'cron')
args, unknownargs = parser.parse_known_args()
sys.argv = sys.argv[:1] + unknownargs

if args.keep: sys.argv.extend(['--define', 'kill=false'])
if args.no_workers:
sys.argv.extend(['--define', 'workers=false'])
else:
sys.argv.extend(['--define', 'workers=true'])
sys.argv.extend(['--define', f"client={'jurism' if args.jurism else 'zotero'}"])
sys.argv.extend(['--define', f'kill={str(not args.keep).lower()}'])
sys.argv.extend(['--define', f'workers={str(args.workers).lower()}'])
if args.stop: sys.argv.append('--stop')

if args.this:
repo = Repository('.')
Expand All @@ -46,38 +61,8 @@ if args.this:
sys.argv.extend(['--tags', branch.replace('gh-', '@') ])
args.nightly = True

## exclude @nightly by default
if os.path.exists(os.path.join(ROOT, '.nightly.json')):
with open(os.path.join(ROOT, '.nightly.json')) as f:
args.nightly = args.nightly or os.environ.get('TRAVIS_BRANCH') in json.load(f)
args.nightly = any([
args.nightly, # requested explicitly from the command line
'#nightly' in os.environ.get('TRAVIS_COMMIT_MESSAGE', ''), # requested explicitly through the commit message
os.environ.get('TRAVIS_TAG', '') != '', # running a release build
os.environ.get('TRAVIS_EVENT_TYPE') == 'cron', # running the nightly build
])
if not args.nightly: sys.argv.extend(['--tags', '~@nightly'])

args.jurism = args.jurism or (os.environ.get('CLIENT') == 'jurism')
if args.jurism:
sys.argv.extend(['--define', f'client=jurism'])
else:
sys.argv.extend(['--define', f'client=zotero'])

if 'CI' in os.environ: # set up for CI
oddjob = (os.environ['JOB'] == '2')

if os.environ.get('TRAVIS_EVENT_TYPE') == 'cron' and os.environ.get('TRAVIS_TAG', '') == '': # don't run beta on tagged builds
args.beta = oddjob

else: # run regular tests
sys.argv.extend(['--tags', f'{"~" if oddjob else ""}@test-cluster-1'])

else: # local client run
## stop on first error by default
if not args.no_stop: sys.argv.append('--stop')

# build before test unless on CI
JOB_NUMBER = int(re.search(r'^[0-9]+\.([0-9]+)$', os.environ.get('TRAVIS_JOB_NUMBER', '0.0')).group(1))
if JOB_NUMBER == 0: # local run
process = subprocess.Popen(['npm', 'run', 'build'], stdout=subprocess.PIPE)
while True:
line = process.stdout.readline()
Expand All @@ -88,19 +73,20 @@ else: # local client run
print(f'Build exited with exit code {returncode}')
sys.exit(returncode)

elif args.nightly and not args.tagged: # only test for beta o
args.beta = (JOB_NUMBER % 2) == 1
args.slow = True

else:
sys.argv.extend(['--tags', f"{'~' if (JOB_NUMBER % 2) == 1 else ''}@test-cluster-1"])
args.slow = args.slow or args.tagged

if args.jurism or args.beta:
if args.jurism:
client = 'juris-m'
else:
client = 'zotero'
if args.beta:
beta = ' BETA'
else:
beta = ''
print(f'********* SKIPPING{beta.upper()} BUILD FOR {client.upper()} UNTIL FURTHER NOTICE ****************')
print(f"********* SKIPPING{' BETA' if args.beta else ''} BUILD FOR {'JURIS-M' if args.jurism else 'ZOTERO'} UNTIL FURTHER NOTICE ****************")
sys.exit()

if args.beta: sys.argv.extend(['--define', f'beta=true'])
if args.slow: sys.argv.extend(['--tags', '~@slow'])
sys.argv.extend(['--define', f'beta={str(args.beta).lower()}'])
print(' '.join(sys.argv), args)

#https://stackoverflow.com/questions/28829350/run-python-behave-from-python-instead-of-command-line
Expand Down
4 changes: 2 additions & 2 deletions test/features/export.feature
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ Scenario: automatic tags in export #1270
Then an export using "Better BibTeX" should match "export/*.bibtex"

# tests the cache
@rbwl @zotero @nightly @timeout=3000
@rbwl @zotero @slow @timeout=3000
Scenario: Really Big whopping library
When I restart Zotero with "1287" + "export/*.json"
And I reset the cache
Expand All @@ -472,7 +472,7 @@ Scenario: Really Big whopping library
And an export using "Better BibTeX" should match "export/*.bibtex", but take no more than 150 seconds
And an export using "Better CSL JSON" should match "export/*.csl.json", but take no more than 150 seconds

@1296 @zotero @nightly @timeout=300
@1296 @zotero @slow @timeout=300
Scenario: Cache does not seem to fill #1296
When I restart Zotero with "1296"
And I empty the trash
Expand Down
4 changes: 2 additions & 2 deletions test/features/import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Scenario: AUX scanner
And I import 1 reference from "import/*.aux"
Then the library should match "import/*-post.json"

@nightly @873 @timeout=240
@873 @slow @timeout=240
Scenario Outline: Better BibTeX Import
When I import <references> references from "import/<file>.bib"
Then the library should match "import/*.json"
Expand Down Expand Up @@ -125,7 +125,7 @@ Scenario: Unabbreviate on import #1436-1
Scenario: Unabbreviate on import #1436-2
When I import 1053 references from "import/*.bib" into a new collection
Then the library should match "import/*.json"
@1436 @nightly @timeout=3000
@1436 @slow @timeout=3000
Scenario: Unabbreviate on import #1436-3
When I import 7166 references from "import/*.bib" into a new collection
Then the library should match "import/*.json"

0 comments on commit 77a88e6

Please sign in to comment.