git @ Cat's Eye Technologies Falderal / rel_0_13
Merge pull request #11 from catseye/develop-0.13 Develop 0.13 Chris Pressey authored 11 months ago GitHub committed 11 months ago
6 changed file(s) with 105 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
22 *.hi
33 *.pyc
44 *.actual
5 /venv/
6 /build/
7 /dist/
8 *.egg-info/
00 History
11 =======
2
3 Version 0.13 "Merchandise Mart":
4
5 * Use `ArgumentParser` instead of `OptionParser` internally.
6 * `--substring-error` is now the default behaviour, and if this
7 option is given, it will be ignored. After a long time
8 considering the problem, we finally determined that it does
9 not make sense to insist that different implementations
10 produce the exact same error message.
11 * `--verbose` option now prints out commands for each test as it
12 is run.
13 * Added conventional `--version` option.
14 * Planned to be the last 0.x series release before 1.0.
15 * Added `setup.py` so that Falderal can be treated as a Python
16 package.
217
318 Version 0.12 "Schoenhofen Brewery":
419
00 Falderal
11 ========
22
3 Version 0.12 "Schoenhofen Brewery"
3 Version 0.13 "Merchandise Mart"
44
55 This is the reference distribution of Falderal, a file format for literate
66 test suites. What sets Falderal apart from most other test frameworks is
1515 * being embedded in Markdown documents
1616
1717 Falderal in three words: "Doctests for DSLs".
18
19 If you're more interested in running the tools than learning about the format
20 itself, skip down to [Implementation](#implementation).
1821
1922 Motivation
2023 ----------
107110 [`doc/Falderal_Literate_Test_Format.markdown`](doc/Falderal_Literate_Test_Format.markdown).
108111 (Note that this specification should not be expected to remain stable
109112 through the 0.x version series.) There are other documents in there too.
110 * `bin/falderal` — the reference implementation of Falderal, written in
111 Python and sometimes referred to as "py-falderal". It imports the
112 sources in `src/falderal`. You don't need to install it; just add
113 the `bin` directory of this distribution to your `$PATH`. This
114 implementation is (somewhat) documented in `doc/py-falderal.markdown`.
113 * `bin/falderal` — the reference implementation of Falderal.
114 See "Implementation", below, for details.
115115 * `script` — miscellaneous small tools intended to be used in tests.
116116 * `src` — source code for py-falderal.
117117 * `tests` — a set of tests for Falderal itself. (Note that these are not
119119 * `HISTORY.markdown` — changelog for releases of Falderal.
120120 * `TODO.markdown` — areas where Falderal and its implementations could be
121121 improved.
122
123 Implementation
124 --------------
125
126 This distribution contains `falderal`, which is the reference implementation
127 of Falderal, written in Python and sometimes referred to as "py-falderal".
128
129 To use it, you can clone this repository and run it as `bin/falderal`
130 from the directory of your clone, or you can put the `bin` directory
131 on your executable search path, and run it as `falderal` anywhere.
132
133 Or you can install it using `pip`:
134
135 pip install -e Falderal==0.13
136
137 (Depending on your needs, you may wish to establish a virtual environment
138 first. Describing how to do so is outside the scope of this document.)
139
140 The implementation is (somewhat) documented in `doc/py-falderal.markdown`.
122141
123142 Development
124143 -----------
0 import setuptools
1
2
3 with open("README.markdown", "r") as fh:
4 long_description = fh.read()
5
6 setuptools.setup(
7 name='Falderal',
8 version='0.13',
9 description='Definition of, and tools for using, the Falderal literate testing format',
10 long_description=long_description,
11 long_description_content_type="text/markdown",
12 author='Chris Pressey',
13 author_email='packages@catseye.tc',
14 url='https://catseye.tc/node/Falderal',
15 packages=['falderal'],
16 package_dir={'': 'src'},
17 scripts=['bin/falderal'],
18 classifiers=[
19 "Development Status :: 4 - Beta",
20 "Intended Audience :: Developers",
21 "License :: OSI Approved :: BSD License",
22 "Operating System :: OS Independent",
23 "Programming Language :: Python :: 2.7",
24 "Programming Language :: Python :: 3",
25 "Topic :: Software Development :: Testing",
26 ],
27 )
11 Usage: falderal [<option>...] <filename.markdown>...
22 """
33
4 from optparse import OptionParser
4 from argparse import ArgumentParser
55 import sys
66
77 from falderal.objects import Document, FalderalSyntaxError
1616 ##### Main #####
1717
1818 def main(args):
19 parser = OptionParser()
20 parser.add_option("-b", "--substring-error",
21 action="store_true", default=False,
22 help="match expected errors as substrings")
23 parser.add_option("--cavalier",
24 action="store_true", default=False,
25 help="don't perform sanity linting before running tests")
26 parser.add_option("-d", "--dump",
27 action="store_true", default=False,
28 help="print out info about parsed tests, don't run them")
29 parser.add_option("-v", "--verbose",
30 action="store_true", default=False,
31 help="print out info about each test as it is run")
19 argparser = ArgumentParser()
20 argparser.add_argument('input_files', nargs='+', metavar='FILENAME', type=str,
21 help='Falderal files containing the tests to use')
22 argparser.add_argument("-b", "--substring-error",
23 action="store_true", default=False,
24 help="no effect (provided for backwards compatibility)")
25 argparser.add_argument("--cavalier",
26 action="store_true", default=False,
27 help="don't perform sanity linting before running tests")
28 argparser.add_argument("-d", "--dump",
29 action="store_true", default=False,
30 help="print out info about parsed tests, don't run them")
31 argparser.add_argument("-v", "--verbose",
32 action="store_true", default=False,
33 help="print out info about each test as it is run")
34 argparser.add_argument('--version', action='version', version="%(prog)s 0.13")
3235
33 (options, args) = parser.parse_args(args[1:])
36 options = argparser.parse_args(args[1:])
37
38 if not options.substring_error:
39 if options.verbose:
40 print("NOTE: --substring-error is now default, option has no effect")
41 options.substring_error = True
3442
3543 # load Documents and create Falderal Tests from them
3644 documents = []
3745 functionalities = {}
3846 tests = []
3947 try:
40 for filename in args:
48 for filename in options.input_files:
4149 documents.append(Document.load(filename))
4250 for document in documents:
4351 tests += document.extract_tests(functionalities)
524524 def __init__(self):
525525 pass
526526
527 def run(self, body=None, input=None):
527 def run(self, body=None, input=None, verbose=False):
528528 """Returns the RunResult of running this implementation on the
529529 given test body and input.
530530
547547 def __str__(self):
548548 return u'callable "%r"' % self.callable
549549
550 def run(self, body=None, input=None):
550 def run(self, body=None, input=None, verbose=False):
551551 try:
552552 result = self.callable(body, input)
553553 return OutputOutcome(result)
573573 `value`, but make sure `value` is properly shell-escaped first."""
574574 return command.replace(var_name, shlex_quote(value))
575575
576 def run(self, body=None, input=None):
576 def run(self, body=None, input=None, verbose=False):
577577 # first, expand all known variables in the command, using subst().
578578 test_filename = None
579579 output_filename = None
623623 os.close(fd)
624624 # replace all occurrences in command
625625 command = self.subst(command, '%(output-file)', output_filename)
626
627 if verbose:
628 print(self, command)
626629
627630 # subshell the command and return the output
628631 pipe = Popen(command, shell=True,
717720 """
718721 results = []
719722 for implementation in self.functionality.implementations:
720 result = implementation.run(body=self.body, input=self.input)
723 result = implementation.run(
724 body=self.body, input=self.input, verbose=options.verbose
725 )
721726 if self.judge(result, options):
722727 results.append(Success(self, implementation))
723728 else: