def parse_references_check_good(): good = [ 'v:analyzer/test/statistic', 'v:analyzer/test/statistic@2016-12-01', 'v:analyzer/log/statistic~master@2016-12-01', 'v:analyzer/log/statistic~master', ] for g in good: parse_reference(g)
def _parse_regression_test_check(line): line = line.strip() tokens = line.split(' ') if len(tokens) != 3: msg = 'I expect exactly 3 tokens.\nLine: "%s"\nTokens: %s' % (line, tokens) raise DTConfigException(msg) try: ref1 = parse_reference(tokens[0]) binary = parse_binary(tokens[1]) ref2 = parse_reference(tokens[2]) evaluable = BinaryEval(ref1, binary, ref2) except RTParseError as e: msg = 'Cannot parse string "%s".' % line raise_wrapped(RTParseError, e, msg, compact=True) return Wrapper(evaluable)
def _parse_regression_test_check(line: str) -> Wrapper: line = line.strip() delim = " " tokens = line.split(delim) if len(tokens) != 3: msg = f'I expect exactly 3 tokens with delimiter {delim}.\nLine: "{line}"\nTokens: {tokens}' raise dtu.DTConfigException(msg) try: ref1 = parse_reference(tokens[0]) binary = parse_binary(tokens[1]) ref2 = parse_reference(tokens[2]) evaluable = BinaryEval(ref1, binary, ref2) except RTParseError as e: msg = f'Cannot parse string "{line}".' dtu.raise_wrapped(RTParseError, e, msg, compact=True) raise return Wrapper(evaluable)
def parse_condition_check_bad(): bad = [ 'v:analyzer/test', 'v:analyzer/test/statistic@2016-12-0a', 'v:analyzer/test/statistic@', 'v:analyzer/test/statistic~', 'v:analyzer/test/statistic~@2016-12-01', ] for b in bad: try: res = parse_reference(b) except RTParseError: pass else: msg = 'Expected DTParseError.' msg += '\nString: %r' % b msg += '\nReturns: %s' % res raise Exception(msg)
def parse_condition_check_bad(): bad = [ "v:analyzer/test", "v:analyzer/test/statistic@2016-12-0a", "v:analyzer/test/statistic@", "v:analyzer/test/statistic~", "v:analyzer/test/statistic~@2016-12-01", ] for b in bad: try: res = parse_reference(b) except RTParseError: pass else: msg = "Expected DTParseError." msg += f"\nString: {b!r}" msg += f"\nReturns: {res}" raise Exception(msg)
def parse_one(): s = 'v:analyzer/log/statistic?hash' a = parse_reference(s) assert a.commit == 'hash', a print a
def parse_one(): s = "v:analyzer/log/statistic?hash" a = parse_reference(s) assert a.commit == "hash", a print(a)