diff options
author | Craig Earls <enderw88@gmail.com> | 2014-12-30 20:48:52 -0800 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2014-12-30 20:48:52 -0800 |
commit | 7cd3a7fc9d6af64846a742bdd2ad07cb6dde0bf9 (patch) | |
tree | 7c569daa1137920ad3cc9ab32d574d24e24d0dc6 /test/DocTests.py | |
parent | b6cef4bc507712427e9c5e83495ba5104679712d (diff) | |
parent | 8e79b3c7c74081b63f9d8b1e0ec97478f61d4ba8 (diff) | |
download | fork-ledger-7cd3a7fc9d6af64846a742bdd2ad07cb6dde0bf9.tar.gz fork-ledger-7cd3a7fc9d6af64846a742bdd2ad07cb6dde0bf9.tar.bz2 fork-ledger-7cd3a7fc9d6af64846a742bdd2ad07cb6dde0bf9.zip |
Merge commit '8e79b3c7c74081b63f9d8b1e0ec97478f61d4ba8'
Diffstat (limited to 'test/DocTests.py')
-rwxr-xr-x | test/DocTests.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/test/DocTests.py b/test/DocTests.py index be28fae1..ea32608e 100755 --- a/test/DocTests.py +++ b/test/DocTests.py @@ -16,6 +16,7 @@ class DocTests: self.ledger = os.path.abspath(args.ledger) self.sourcepath = os.path.abspath(args.file) self.verbose = args.verbose + self.tests = args.examples self.examples = dict() self.test_files = list() @@ -114,7 +115,7 @@ class DocTests: if command[0] == '$': command.remove('$') index = command.index('ledger') command[index] = self.ledger - for i,argument in enumerate('--init-file /dev/null --columns 80'.split()): + for i,argument in enumerate('--args-only --columns 80'.split()): command.insert(index+i+1, argument) try: @@ -133,7 +134,14 @@ class DocTests: def test_examples(self): failed = set() - for test_id in self.examples: + tests = self.examples.keys() + if self.tests: + tests = list(set(self.tests).intersection(tests)) + temp = list(set(self.tests).difference(tests)) + if len(temp) > 0: + print >> sys.stderr, 'Skipping non-existent examples: %s' % ', '.join(temp) + + for test_id in tests: validation = False if "validate-data" in self.examples[test_id] or "validate-command" in self.examples[test_id]: validation = True @@ -213,7 +221,7 @@ class DocTests: if __name__ == "__main__": def getargs(): - parser = argparse.ArgumentParser(description='DocTests', prefix_chars='-') + parser = argparse.ArgumentParser(prog='DocTests', description='Test ledger examples from the documentation', prefix_chars='-') parser.add_argument('-v', '--verbose', dest='verbose', action='count', @@ -230,6 +238,11 @@ if __name__ == "__main__": action='store', required=True, help='the texinfo documentation file to run the examples from') + parser.add_argument('examples', + metavar='EXAMPLE', + type=str, + nargs='*', + help='the examples to test') return parser.parse_args() args = getargs() |