diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/CheckBaselineTests.py | 29 | ||||
-rwxr-xr-x | test/CheckOptions.py | 57 | ||||
-rwxr-xr-x | test/CheckTexinfo.py | 3 | ||||
-rw-r--r-- | test/baseline/opt-permissive.test | 19 | ||||
-rw-r--r-- | test/regress/634AA589.test | 19 |
5 files changed, 67 insertions, 60 deletions
diff --git a/test/CheckBaselineTests.py b/test/CheckBaselineTests.py index 404c12db..3c3e590b 100755 --- a/test/CheckBaselineTests.py +++ b/test/CheckBaselineTests.py @@ -18,6 +18,35 @@ class CheckBaselineTests (CheckOptions): CheckOptions.__init__(self, args) self.missing_baseline_tests = set() + self.untested_options = [ + 'anon', + 'args-only', + 'cache', + 'debug', + 'download', + 'file', + 'force-color', + 'force-pager', + 'full-help', + 'help', + 'help-calc', + 'help-comm', + 'help-disp', + 'import', + 'init-file', + 'no-color', + 'options', + 'price-db', + 'price-exp', + 'revalued-total', + 'script', + 'seed', + 'trace', + 'verbose', + 'verify', + 'version' + ] + def main(self): for option in self.ledger_options(): if option in self.untested_options: continue diff --git a/test/CheckOptions.py b/test/CheckOptions.py index d9565600..124ce197 100755 --- a/test/CheckOptions.py +++ b/test/CheckOptions.py @@ -3,10 +3,12 @@ from __future__ import print_function -import sys import re import os +import sys +import shlex import argparse +import subprocess from os.path import * from subprocess import Popen, PIPE @@ -24,48 +26,22 @@ class CheckOptions (object): self.missing_options = set() self.unknown_options = set() - self.untested_options = [ - 'anon', - 'args-only', - 'cache', - 'debug', - 'download', - 'file', - 'force-color', - 'force-pager', - 'full-help', - 'help', - 'help-calc', - 'help-comm', - 'help-disp', - 'import', - 'init-file', - 'no-color', - 'options', - 'price-db', - 'price-exp', - 'revalued-total', - 'script', - 'seed', - 'trace', - 'verbose', - 'verify', - 'version' - ] - - self.known_alternates = [ - 'cost', - 'first', - 'import', - 'last', - 'leeway', - 'period-sort' - ] - def find_options(self, filename): regex = re.compile(self.option_pattern) return {match.group(1) for match in {regex.match(line) for line in open(filename)} if match} + def find_alternates(self): + regex = re.compile(r'OPT_ALT\([^,]*,\s*([^)]+?)_?\)'); + command = shlex.split('grep --no-filename OPT_ALT') + for source_file in ['session', 'report']: + command.append(os.path.join(self.source, 'src', '%s.cc' % source_file)) + try: + output = subprocess.check_output(command).split('\n'); + except subprocess.CalledProcessError: + output = '' + alternates = {match.group(1).replace('_', '-') for match in {regex.search(line) for line in output} if match} + return alternates + def ledger_options(self): pipe = Popen('%s --debug option.names parse true' % self.ledger, shell=True, stdout=PIPE, stderr=PIPE) @@ -82,7 +58,8 @@ class CheckOptions (object): else: options.remove(option) - self.unknown_options = {option for option in options if option not in self.known_alternates} + known_alternates = self.find_alternates() + self.unknown_options = {option for option in options if option not in known_alternates} if len(self.missing_options): print("Missing %s entries for:%s%s\n" % (self.source_type, self.sep, self.sep.join(sorted(list(self.missing_options))))) diff --git a/test/CheckTexinfo.py b/test/CheckTexinfo.py index eedd975d..34d0e153 100755 --- a/test/CheckTexinfo.py +++ b/test/CheckTexinfo.py @@ -30,6 +30,7 @@ class CheckTexinfo (CheckOptions): item_regex = re.compile('^@item --([-A-Za-z]+)') itemx_regex = re.compile('^@itemx') fix_regex = re.compile('FIX') + comment_regex = re.compile('^\s*@c') for line in open(filename): line = line.strip() if state == state_normal: @@ -50,7 +51,7 @@ class CheckTexinfo (CheckOptions): opt_doc = str() elif itemx_regex.match(line): continue - else: + elif not comment_regex.match(line): opt_doc += line return options diff --git a/test/baseline/opt-permissive.test b/test/baseline/opt-permissive.test index e69de29b..8f8ff031 100644 --- a/test/baseline/opt-permissive.test +++ b/test/baseline/opt-permissive.test @@ -0,0 +1,19 @@ + +; The option --permissive quiets balance assertions + +2014-05-01 * Opening balance + Assets:Cash $100 + Equity:Opening balance + +2014-05-10 * Spend money + Expenses:Foo $10 + Assets:Cash -$10 = $80 + +test bal --permissive + $90 Assets:Cash + $-100 Equity:Opening balance + $10 Expenses:Foo +-------------------- + 0 +end test + diff --git a/test/regress/634AA589.test b/test/regress/634AA589.test deleted file mode 100644 index 8f8ff031..00000000 --- a/test/regress/634AA589.test +++ /dev/null @@ -1,19 +0,0 @@ - -; The option --permissive quiets balance assertions - -2014-05-01 * Opening balance - Assets:Cash $100 - Equity:Opening balance - -2014-05-10 * Spend money - Expenses:Foo $10 - Assets:Cash -$10 = $80 - -test bal --permissive - $90 Assets:Cash - $-100 Equity:Opening balance - $10 Expenses:Foo --------------------- - 0 -end test - |