import argparse
+import enum
import os
import shlex
import sys
import lit.util
+class TestOrder(enum.Enum):
+ EARLY_TESTS_THEN_BY_NAME = enum.auto()
+ FAILING_FIRST = enum.auto()
+ RANDOM = enum.auto()
+
+
def parse_args():
parser = argparse.ArgumentParser(prog='lit')
parser.add_argument('test_paths',
if opts.echoAllCommands:
opts.showOutput = True
- # TODO(python3): Could be enum
if opts.shuffle:
- opts.order = 'random'
+ opts.order = TestOrder.RANDOM
elif opts.incremental:
- opts.order = 'failing-first'
+ opts.order = TestOrder.FAILING_FIRST
else:
- opts.order = 'default'
+ opts.order = TestOrder.EARLY_TESTS_THEN_BY_NAME
if opts.numShards or opts.runShard:
if not opts.numShards or not opts.runShard:
def determine_order(tests, order):
- assert order in ['default', 'random', 'failing-first']
- if order == 'default':
+ from lit.cl_arguments import TestOrder
+ if order == TestOrder.EARLY_TESTS_THEN_BY_NAME:
tests.sort(key=lambda t: (not t.isEarlyTest(), t.getFullName()))
- elif order == 'random':
- import random
- random.shuffle(tests)
- else:
+ elif order == TestOrder.FAILING_FIRST:
def by_mtime(test):
return os.path.getmtime(test.getFilePath())
tests.sort(key=by_mtime, reverse=True)
+ elif order == TestOrder.RANDOM:
+ import random
+ random.shuffle(tests)
def touch_file(test):
def progress_callback(test):
display.update(test)
- if opts.order == 'failing-first':
+ if opts.order == lit.cl_arguments.TestOrder.FAILING_FIRST:
touch_file(test)
run = lit.run.Run(tests, lit_config, workers, progress_callback,