cram-0.6/0000755000076500000240000000000012176557607012710 5ustar brodiestaff00000000000000cram-0.6/.coveragerc0000644000076500000240000000007011453172453015013 0ustar brodiestaff00000000000000[report] exclude_lines = if __name__ == '__main__': cram-0.6/.pylintrc0000644000076500000240000000154311524174237014546 0ustar brodiestaff00000000000000[MESSAGES CONTROL] # The design check gives mostly useless advice. # R0201: method could be a function # W0141: used range # W0142: * or ** arguments # W0201: attribute defined outside of __init__ disable=design,R0201,W0141,W0142,W0201 [REPORTS] include-ids=yes reports=no [TYPECHECK] ignored-classes= generated-members= [BASIC] const-rgx=(([a-zA-Z_][a-zA-Z0-9_]{2,30})|(__[a-z0-9_]{2,30}__))$ class-rgx=[a-zA-Z_][a-zA-Z0-9]{2,30}$ function-rgx=[a-z_][a-z0-9_]{2,30}$ method-rgx=[a-z_][a-z0-9_]{2,30}$ attr-rgx=[a-z_][a-z0-9_]{0,30}$ argument-rgx=[a-z_][a-z0-9_]{0,30}$ variable-rgx=[a-z_][a-z0-9_]{0,30}$ inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ [CLASSES] ignore-iface-methods= defining-attr-methods=__init__,__new__ [IMPORTS] deprecated-modules=regsub,TERMIOS,Bastion,rexec [FORMAT] max-line-length=79 max-module-lines=5000 [MISCELLANEOUS] notes=FIXME,XXX,TODO cram-0.6/contrib/0000755000076500000240000000000012176557607014350 5ustar brodiestaff00000000000000cram-0.6/contrib/cram.vim0000644000076500000240000000245611744145154016004 0ustar brodiestaff00000000000000" Vim syntax file " Language: Cram Tests " Author: Steve Losh (steve@stevelosh.com) " " Add the following line to your ~/.vimrc to enable: " au BufNewFile,BufRead *.t set filetype=cram " " If you want folding you'll need the following line as well: " let cram_fold=1 " " You might also want to set the starting foldlevel for Cram files: " autocmd Syntax cram setlocal foldlevel=1 if exists("b:current_syntax") finish endif syn include @Shell syntax/sh.vim syn match cramComment /^[^ ].*$/ syn region cramOutput start=/^ [^$>]/ start=/^ $/ end=/\v.(\n\n*[^ ])\@=/me=s end=/^ [$>]/me=e-3 end=/^$/ fold containedin=cramBlock syn match cramCommandStart /^ \$ / containedin=cramCommand syn region cramCommand start=/^ \$ /hs=s+4,rs=s+4 end=/^ [^>]/me=e-3 end=/^ $/me=e-2 containedin=cramBlock contains=@Shell keepend syn region cramBlock start=/^ /ms=e-2 end=/\v.(\n\n*[^ ])\@=/me=s end=/^$/me=e-1 fold keepend hi link cramCommandStart Keyword hi link cramComment Normal hi link cramOutput Comment if exists("cram_fold") setlocal foldmethod=syntax endif syn sync match cramSync grouphere NONE "^$" syn sync maxlines=200 " It's okay to set tab settings here, because an indent of two spaces is specified " by the file format. setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab let b:current_syntax = "cram" cram-0.6/COPYING.txt0000644000076500000240000004311011445077455014554 0ustar brodiestaff00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. cram-0.6/cram.py0000755000076500000240000004365212176553101014202 0ustar brodiestaff00000000000000#!/usr/bin/env python """Functional testing framework for command line applications""" import difflib import itertools import optparse import os import re import signal import subprocess import sys import shutil import time import tempfile try: import configparser except ImportError: import ConfigParser as configparser __all__ = ['main', 'test'] def findtests(paths): """Yield tests in paths in sorted order""" for p in paths: if os.path.isdir(p): for root, dirs, files in os.walk(p): if os.path.basename(root).startswith('.'): continue for f in sorted(files): if not f.startswith('.') and f.endswith('.t'): yield os.path.normpath(os.path.join(root, f)) else: yield os.path.normpath(p) def regex(pattern, s): """Match a regular expression or return False if invalid. >>> [bool(regex(r, 'foobar')) for r in ('foo.*', '***')] [True, False] """ try: return re.match(pattern + r'\Z', s) except re.error: return False def glob(el, l): r"""Match a glob-like pattern. The only supported special characters are * and ?. Escaping is supported. >>> bool(glob(r'\* \\ \? fo?b*', '* \\ ? foobar')) True """ i, n = 0, len(el) res = '' while i < n: c = el[i] i += 1 if c == '\\' and el[i] in '*?\\': res += el[i - 1:i + 1] i += 1 elif c == '*': res += '.*' elif c == '?': res += '.' else: res += re.escape(c) return regex(res, l) annotations = {'glob': glob, 're': regex} def match(el, l): """Match patterns based on annotations""" for k in annotations: ann = ' (%s)\n' % k if el.endswith(ann) and annotations[k](el[:-len(ann)], l[:-1]): return True return False class SequenceMatcher(difflib.SequenceMatcher, object): """Like difflib.SequenceMatcher, but matches globs and regexes""" def find_longest_match(self, alo, ahi, blo, bhi): """Find longest matching block in a[alo:ahi] and b[blo:bhi]""" # SequenceMatcher uses find_longest_match() to slowly whittle down # the differences between a and b until it has each matching block. # Because of this, we can end up doing the same matches many times. matches = [] for n, (el, line) in enumerate(zip(self.a[alo:ahi], self.b[blo:bhi])): if el != line and match(el, line): # This fools the superclass's method into thinking that the # regex/glob in a is identical to b by replacing a's line (the # expected output) with b's line (the actual output). self.a[alo + n] = line matches.append((n, el)) ret = super(SequenceMatcher, self).find_longest_match(alo, ahi, blo, bhi) # Restore the lines replaced above. Otherwise, the diff output # would seem to imply that the tests never had any regexes/globs. for n, el in matches: self.a[alo + n] = el return ret def unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n', matcher=SequenceMatcher): """Compare two sequences of lines; generate the delta as a unified diff. This is like difflib.unified_diff(), but allows custom matchers. """ started = False for group in matcher(None, a, b).get_grouped_opcodes(n): if not started: fromdate = fromfiledate and '\t%s' % fromfiledate or '' todate = fromfiledate and '\t%s' % tofiledate or '' yield '--- %s%s%s' % (fromfile, fromdate, lineterm) yield '+++ %s%s%s' % (tofile, todate, lineterm) started = True i1, i2, j1, j2 = group[0][1], group[-1][2], group[0][3], group[-1][4] yield "@@ -%d,%d +%d,%d @@%s" % (i1 + 1, i2 - i1, j1 + 1, j2 - j1, lineterm) for tag, i1, i2, j1, j2 in group: if tag == 'equal': for line in a[i1:i2]: yield ' ' + line continue if tag == 'replace' or tag == 'delete': for line in a[i1:i2]: yield '-' + line if tag == 'replace' or tag == 'insert': for line in b[j1:j2]: yield '+' + line needescape = re.compile(r'[\x00-\x09\x0b-\x1f\x7f-\xff]').search escapesub = re.compile(r'[\x00-\x09\x0b-\x1f\\\x7f-\xff]').sub escapemap = dict((chr(i), r'\x%02x' % i) for i in range(256)) escapemap.update({'\\': '\\\\', '\r': r'\r', '\t': r'\t'}) def escape(s): """Like the string-escape codec, but doesn't escape quotes""" return escapesub(lambda m: escapemap[m.group(0)], s[:-1]) + ' (esc)\n' def makeresetsigpipe(): """Make a function to reset SIGPIPE to SIG_DFL (for use in subprocesses). Doing subprocess.Popen(..., preexec_fn=makeresetsigpipe()) will prevent Python's SIGPIPE handler (SIG_IGN) from being inherited by the child process. """ if sys.platform == 'win32' or getattr(signal, 'SIGPIPE', None) is None: return None return lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL) def test(path, shell, indent=2): """Run test at path and return input, output, and diff. This returns a 3-tuple containing the following: (list of lines in test, same list with actual output, diff) diff is a generator that yields the diff between the two lists. If a test exits with return code 80, the actual output is set to None and diff is set to []. """ indent = ' ' * indent cmdline = '%s$ ' % indent conline = '%s> ' % indent f = open(path) abspath = os.path.abspath(path) env = os.environ.copy() env['TESTDIR'] = os.path.dirname(abspath) env['TESTFILE'] = os.path.basename(abspath) p = subprocess.Popen([shell, '-'], bufsize=-1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, env=env, preexec_fn=makeresetsigpipe(), close_fds=os.name == 'posix') salt = 'CRAM%s' % time.time() after = {} refout, postout = [], [] i = pos = prepos = -1 stdin = [] for i, line in enumerate(f): refout.append(line) if line.startswith(cmdline): after.setdefault(pos, []).append(line) prepos = pos pos = i stdin.append('echo "\n%s %s $?"\n' % (salt, i)) stdin.append(line[len(cmdline):]) elif line.startswith(conline): after.setdefault(prepos, []).append(line) stdin.append(line[len(conline):]) elif not line.startswith(indent): after.setdefault(pos, []).append(line) stdin.append('echo "\n%s %s $?"\n' % (salt, i + 1)) output = p.communicate(input=''.join(stdin))[0] if p.returncode == 80: return (refout, None, []) # Add a trailing newline to the input script if it's missing. if refout and not refout[-1].endswith('\n'): refout[-1] += '\n' # We use str.split instead of splitlines to get consistent # behavior between Python 2 and 3. In 3, we use unicode strings, # which has more line breaks than \n and \r. pos = -1 ret = 0 for i, line in enumerate(output[:-1].split('\n')): line += '\n' if line.startswith(salt): presalt = postout.pop() if presalt != '%s\n' % indent: postout.append(presalt[:-1] + ' (no-eol)\n') ret = int(line.split()[2]) if ret != 0: postout.append('%s[%s]\n' % (indent, ret)) postout += after.pop(pos, []) pos = int(line.split()[1]) else: if needescape(line): line = escape(line) postout.append(indent + line) postout += after.pop(pos, []) diffpath = os.path.basename(abspath) diff = unified_diff(refout, postout, diffpath, diffpath + '.err') for firstline in diff: return refout, postout, itertools.chain([firstline], diff) return refout, postout, [] def prompt(question, answers, auto=None): """Write a prompt to stdout and ask for answer in stdin. answers should be a string, with each character a single answer. An uppercase letter is considered the default answer. If an invalid answer is given, this asks again until it gets a valid one. If auto is set, the question is answered automatically with the specified value. """ default = [c for c in answers if c.isupper()] while True: sys.stdout.write('%s [%s] ' % (question, answers)) sys.stdout.flush() if auto is not None: sys.stdout.write(auto + '\n') sys.stdout.flush() return auto answer = sys.stdin.readline().strip().lower() if not answer and default: return default[0] elif answer and answer in answers.lower(): return answer def log(msg=None, verbosemsg=None, verbose=False): """Write msg to standard out and flush. If verbose is True, write verbosemsg instead. """ if verbose: msg = verbosemsg if msg: sys.stdout.write(msg) sys.stdout.flush() def patch(cmd, diff, path): """Run echo [lines from diff] | cmd -p0""" p = subprocess.Popen([cmd, '-p0'], bufsize=-1, stdin=subprocess.PIPE, universal_newlines=True, preexec_fn=makeresetsigpipe(), cwd=path, close_fds=os.name == 'posix') p.communicate(''.join(diff)) return p.returncode == 0 def run(paths, tmpdir, shell, quiet=False, verbose=False, patchcmd=None, answer=None, indent=2): """Run tests in paths in tmpdir. If quiet is True, diffs aren't printed. If verbose is True, filenames and status information are printed. If patchcmd is set, a prompt is written to stdout asking if changed output should be merged back into the original test. The answer is read from stdin. If 'y', the test is patched using patch based on the changed output. """ cwd = os.getcwd() seen = set() basenames = set() skipped = failed = 0 for i, path in enumerate(findtests(paths)): abspath = os.path.abspath(path) if abspath in seen: continue seen.add(abspath) log(None, '%s: ' % path, verbose) if not os.stat(abspath).st_size: skipped += 1 log('s', 'empty\n', verbose) else: basename = os.path.basename(path) if basename in basenames: basename = '%s-%s' % (basename, i) else: basenames.add(basename) testdir = os.path.join(tmpdir, basename) os.mkdir(testdir) try: os.chdir(testdir) refout, postout, diff = test(abspath, shell, indent) finally: os.chdir(cwd) errpath = abspath + '.err' if postout is None: skipped += 1 log('s', 'skipped\n', verbose) elif not diff: log('.', 'passed\n', verbose) if os.path.exists(errpath): os.remove(errpath) else: failed += 1 log('!', 'failed\n', verbose) if not quiet: log('\n', None, verbose) errfile = open(errpath, 'w') try: for line in postout: errfile.write(line) finally: errfile.close() if not quiet: if patchcmd: diff = list(diff) for line in diff: log(line) if (patchcmd and prompt('Accept this change?', 'yN', answer) == 'y'): if patch(patchcmd, diff, os.path.dirname(abspath)): log(None, '%s: merged output\n' % path, verbose) os.remove(errpath) else: log('%s: merge failed\n' % path) log('\n', None, verbose) log('# Ran %s tests, %s skipped, %s failed.\n' % (len(seen), skipped, failed)) return bool(failed) def which(cmd): """Return the patch to cmd or None if not found""" for p in os.environ['PATH'].split(os.pathsep): path = os.path.join(p, cmd) if os.path.isfile(path) and os.access(path, os.X_OK): return os.path.abspath(path) return None def expandpath(path): """Expands ~ and environment variables in path""" return os.path.expanduser(os.path.expandvars(path)) class OptionParser(optparse.OptionParser): """Like optparse.OptionParser, but supports setting values through CRAM= and .cramrc.""" def __init__(self, *args, **kwargs): self._config_opts = {} optparse.OptionParser.__init__(self, *args, **kwargs) def add_option(self, *args, **kwargs): option = optparse.OptionParser.add_option(self, *args, **kwargs) if option.dest and option.dest != 'version': key = option.dest.replace('_', '-') self._config_opts[key] = option.action == 'store_true' return option def parse_args(self, args=None, values=None): config = configparser.RawConfigParser() config.read(expandpath(os.environ.get('CRAMRC', '.cramrc'))) defaults = {} for key, isbool in self._config_opts.items(): try: if isbool: try: value = config.getboolean('cram', key) except ValueError: value = config.get('cram', key) self.error('--%s: invalid boolean value: %r' % (key, value)) else: value = config.get('cram', key) except (configparser.NoSectionError, configparser.NoOptionError): pass else: defaults[key] = value self.set_defaults(**defaults) eargs = os.environ.get('CRAM', '').strip() if eargs: import shlex args = args or [] args += shlex.split(eargs) try: return optparse.OptionParser.parse_args(self, args, values) except optparse.OptionValueError: self.error(str(sys.exc_info()[1])) def main(args): """Main entry point. args should not contain the script name. """ p = OptionParser(usage='cram [OPTIONS] TESTS...', prog='cram') p.add_option('-V', '--version', action='store_true', help='show version information and exit') p.add_option('-q', '--quiet', action='store_true', help="don't print diffs") p.add_option('-v', '--verbose', action='store_true', help='show filenames and test status') p.add_option('-i', '--interactive', action='store_true', help='interactively merge changed test output') p.add_option('-y', '--yes', action='store_true', help='answer yes to all questions') p.add_option('-n', '--no', action='store_true', help='answer no to all questions') p.add_option('-E', '--preserve-env', action='store_true', help="don't reset common environment variables") p.add_option('--keep-tmpdir', action='store_true', help='keep temporary directories') p.add_option('--shell', action='store', default='/bin/sh', metavar='PATH', help='shell to use for running tests') p.add_option('--indent', action='store', default=2, metavar='NUM', type='int', help='number of spaces to use for indentation') opts, paths = p.parse_args(args) if opts.version: sys.stdout.write("""Cram CLI testing framework (version 0.6) Copyright (C) 2010-2011 Brodie Rao and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. """) return conflicts = [('-y', opts.yes, '-n', opts.no), ('-q', opts.quiet, '-i', opts.interactive)] for s1, o1, s2, o2 in conflicts: if o1 and o2: sys.stderr.write('options %s and %s are mutually exclusive\n' % (s1, s2)) return 2 patchcmd = None if opts.interactive: patchcmd = which('patch') if not patchcmd: sys.stderr.write('patch(1) required for -i\n') return 2 if not paths: sys.stdout.write(p.get_usage()) return 2 badpaths = [path for path in paths if not os.path.exists(path)] if badpaths: sys.stderr.write('no such file: %s\n' % badpaths[0]) return 2 tmpdir = os.environ['CRAMTMP'] = tempfile.mkdtemp('', 'cramtests-') proctmp = os.path.join(tmpdir, 'tmp') os.mkdir(proctmp) for s in ('TMPDIR', 'TEMP', 'TMP'): os.environ[s] = proctmp if not opts.preserve_env: for s in ('LANG', 'LC_ALL', 'LANGUAGE'): os.environ[s] = 'C' os.environ['TZ'] = 'GMT' os.environ['CDPATH'] = '' os.environ['COLUMNS'] = '80' os.environ['GREP_OPTIONS'] = '' if opts.yes: answer = 'y' elif opts.no: answer = 'n' else: answer = None try: return run(paths, tmpdir, opts.shell, opts.quiet, opts.verbose, patchcmd, answer, opts.indent) finally: if opts.keep_tmpdir: log('# Kept temporary directory: %s\n' % tmpdir) else: shutil.rmtree(tmpdir) if __name__ == '__main__': try: sys.exit(main(sys.argv[1:])) except KeyboardInterrupt: pass cram-0.6/examples/0000755000076500000240000000000012176557607014526 5ustar brodiestaff00000000000000cram-0.6/examples/.hidden/0000755000076500000240000000000012176557607016037 5ustar brodiestaff00000000000000cram-0.6/examples/.hidden/hidden.t0000644000076500000240000000005211445542620017437 0ustar brodiestaff00000000000000This test is ignored because it's hidden. cram-0.6/examples/.hidden.t0000644000076500000240000000005211445542620016204 0ustar brodiestaff00000000000000This test is ignored because it's hidden. cram-0.6/examples/bare.t0000644000076500000240000000001111445077455015610 0ustar brodiestaff00000000000000 $ true cram-0.6/examples/empty.t0000644000076500000240000000000011445077455016033 0ustar brodiestaff00000000000000cram-0.6/examples/env.t0000644000076500000240000000064112176543260015472 0ustar brodiestaff00000000000000Check environment variables: $ echo "$LANG" C $ echo "$LC_ALL" C $ echo "$LANGUAGE" C $ echo "$TZ" GMT $ echo "$CDPATH" $ echo "$COLUMNS" 80 $ echo "$GREP_OPTIONS" $ echo "$CRAMTMP" .+ (re) $ echo "$TESTDIR" */examples (glob) $ ls "$TESTDIR" bare.t empty.t env.t fail.t missingeol.t skip.t test.t $ echo "$TESTFILE" env.t $ pwd */cramtests*/env.t (glob) cram-0.6/examples/fail.t0000644000076500000240000000061511506360776015623 0ustar brodiestaff00000000000000Output needing escaping: $ printf '\00\01\02\03\04\05\06\07\010\011\013\014\016\017\020\021\022\n' foo $ printf '\023\024\025\026\027\030\031\032\033\034\035\036\037\040\047\n' bar Wrong output and bad regexes: $ echo 1 2 $ printf '1\nfoo\n1\n' +++ (re) foo\ (re) (re) Filler to force a second diff hunk: Offset regular expression: $ printf 'foo\n\n1\n' \d (re) cram-0.6/examples/missingeol.t0000644000076500000240000000003511506360776017055 0ustar brodiestaff00000000000000 $ printf foo foo (no-eol)cram-0.6/examples/skip.t0000644000076500000240000000026311450272420015637 0ustar brodiestaff00000000000000This test is considered "skipped" because it exits with return code 80. This is useful for skipping tests that only work on certain platforms or in certain settings. $ exit 80 cram-0.6/examples/test.t0000644000076500000240000000224012176545727015670 0ustar brodiestaff00000000000000Simple commands: $ echo foo foo $ printf 'bar\nbaz\n' | cat bar baz Multi-line command: $ foo() { > echo bar > } $ foo bar Regular expression: $ echo foobarbaz foobar.* (re) Glob: $ printf '* \\foobarbaz {10}\n' \* \\fo?bar* {10} (glob) Literal match ending in (re) and (glob): $ echo 'foo\Z\Z\Z bar (re)' foo\Z\Z\Z bar (re) $ echo 'baz??? quux (glob)' baz??? quux (glob) Exit code: $ (exit 1) [1] Write to stderr: $ echo foo >&2 foo No newline: $ printf foo foo (no-eol) $ printf 'foo\nbar' foo bar (no-eol) $ printf ' ' (no-eol) $ printf ' \n ' (no-eol) $ echo foo foo $ printf foo foo (no-eol) Escaped output: $ printf '\00\01\02\03\04\05\06\07\010\011\013\014\016\017\020\021\022\n' \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\x0b\x0c\x0e\x0f\x10\x11\x12 (esc) $ printf '\023\024\025\026\027\030\031\032\033\034\035\036\037\040\047\n' \x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ' (esc) Command that closes a pipe: $ cat /dev/urandom | head -1 > /dev/null If Cram let Python's SIGPIPE handler get inherited by this script, we might see broken pipe messages. cram-0.6/Makefile0000644000076500000240000000242312176556715014350 0ustar brodiestaff00000000000000PYTHON=python ifdef PREFIX PREFIX_ARG=--prefix=$(PREFIX) endif all: build build: $(PYTHON) setup.py build clean: -$(PYTHON) setup.py clean --all find . -not -path '*/.hg/*' -name '*.py[cdo]' -exec rm -f '{}' ';' find . -name '*.err' -exec rm -f '{}' ';' rm -rf __pycache__ dist build htmlcov rm -f README.md MANIFEST *,cover .coverage install: build $(PYTHON) setup.py install $(PREFIX_ARG) dist: TAR_OPTIONS="--owner=root --group=root --mode=u+w,go-w,a+rX-s" \ $(PYTHON) setup.py -q sdist tests: ifeq ($(PYTHON),all) python2.4 -tt setup.py -q test python2.5 -tt setup.py -q test python2.6 -tt -3 setup.py -q test python2.7 -tt -3 setup.py -q test python3.2 -tt -bb setup.py -q test python3.3 -tt -bb setup.py -q test else $(PYTHON) -tt setup.py -q test endif coverage: $(PYTHON) setup.py -q test --coverage && \ coverage report && \ coverage annotate # E261: two spaces before inline comment # E301: expected blank line # E302: two new lines between functions/etc. pep8: pep8 --ignore=E125,E261,E301,E302 --repeat cram.py setup.py pyflakes: pyflakes cram.py setup.py pylint: pylint --rcfile=.pylintrc cram.py setup.py markdown: pandoc -f rst -t markdown README.txt > README.md .PHONY: all build clean install dist tests coverage pep8 pyflakes pylint \ markdown cram-0.6/PKG-INFO0000644000076500000240000003522212176557607014011 0ustar brodiestaff00000000000000Metadata-Version: 1.0 Name: cram Version: 0.6 Summary: A simple testing framework for command line applications Home-page: https://bitheap.org/cram/ Author: Brodie Rao Author-email: brodie@bitheap.org License: GNU GPL Download-URL: https://bitheap.org/cram/cram-0.6.tar.gz Description: ====================== Cram: It's test time ====================== Cram is a functional testing framework for command line applications based on Mercurial_'s `unified test format`_. Cram tests look like snippets of interactive shell sessions. Cram runs each command and compares the command output in the test with the command's actual output. Here's a snippet from `Cram's own test suite`_:: The $PYTHON environment variable should be set when running this test from Python. $ [ -n "$PYTHON" ] || PYTHON="`which python`" $ if [ -n "$COVERAGE" ]; then > coverage erase > alias cram="`which coverage` run --branch -a $TESTDIR/../cram.py" > else > alias cram="$PYTHON $TESTDIR/../cram.py" > fi $ command -v md5 > /dev/null || alias md5=md5sum Usage: $ cram -h [Uu]sage: cram \[OPTIONS\] TESTS\.\.\. (re) [Oo]ptions: (re) -h, --help show this help message and exit -V, --version show version information and exit -q, --quiet don't print diffs -v, --verbose show filenames and test status -i, --interactive interactively merge changed test output -y, --yes answer yes to all questions -n, --no answer no to all questions -E, --preserve-env don't reset common environment variables --keep-tmpdir keep temporary directories --shell=PATH shell to use for running tests --indent=NUM number of spaces to use for indentation The format in a nutshell: * Cram tests use the ``.t`` file extension. * Lines beginning with two spaces, a dollar sign, and a space are run in the shell. * Lines beginning with two spaces, a greater than sign, and a space allow multi-line commands. * All other lines beginning with two spaces are considered command output. * Output lines ending with a space and the keyword ``(re)`` are matched as `Perl-compatible regular expressions`_. * Lines ending with a space and the keyword ``(glob)`` are matched with a glob-like syntax. The only special characters supported are ``*`` and ``?``. Both characters can be escaped using ``\``, and the backslash can be escaped itself. * Output lines ending with either of the above keywords are always first matched literally with actual command output. * Lines ending with a space and the keyword ``(no-eol)`` will match actual output that doesn't end in a newline. * Actual output lines containing unprintable characters are escaped and suffixed with a space and the keyword ``(esc)``. Lines matching unprintable output must also contain the keyword. * Anything else is a comment. .. _Mercurial: http://mercurial.selenic.com/ .. _unified test format: http://www.selenic.com/blog/?p=663 .. _Cram's own test suite: https://bitbucket.org/brodie/cram/src/tip/tests/cram.t .. _Perl-compatible regular expressions: https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions Download -------- * cram-0.6.tar.gz_ (24 KB, requires Python 2.4-2.7 or Python 3.1-3.2) .. _cram-0.6.tar.gz: https://bitheap.org/cram/cram-0.6.tar.gz Installation ------------ You can use pip_ to install Cram:: $ pip install cram Or you can install Cram using GNU make:: $ wget https://bitheap.org/cram/cram-0.6.tar.gz $ tar zxvf cram-0.6.tar.gz $ cd cram-0.6 $ make install .. _pip: https://pypi.python.org/pypi/pip Usage ----- Cram will print a dot for each passing test. If a test fails, a `unified context diff`_ is printed showing the test's expected output and the actual output. Skipped tests (empty tests and tests that exit with return code ``80``) are marked with ``s`` instead of a dot. For example, if we run Cram on `its own example tests`_:: .s.! --- /home/brodie/src/cram/examples/fail.t +++ /home/brodie/src/cram/examples/fail.t.err @@ -3,21 +3,22 @@ $ echo 1 1 $ echo 1 - 2 + 1 $ echo 1 1 Invalid regex: $ echo 1 - +++ (re) + 1 Offset regular expression: $ printf 'foo\nbar\nbaz\n\n1\nA\n@\n' foo + bar baz \d (re) [A-Z] (re) - # + @ s. # Ran 6 tests, 2 skipped, 1 failed. Cram will also write the test with its actual output to ``examples/fail.t.err``. When you're first writing a test, you might just write the commands and run the test to see what happens. If you run Cram with ``-i`` or ``--interactive``, you'll be prompted to merge the actual output back into the test. This makes it easy to quickly prototype new tests. You can specify a default set of options by creating a ``.cramrc`` file. For example:: [cram] verbose = True indent = 4 Is the same as invoking Cram with ``--verbose`` and ``--indent=4``. To change what configuration file Cram loads, you can set the ``CRAMRC`` environment variable. You can also specify command line options in the ``CRAM`` environment variable. Note that the following environment variables are reset before tests are run: * ``TMPDIR``, ``TEMP``, and ``TMP`` are set to the test runner's ``tmp`` directory. * ``LANG``, ``LC_ALL``, and ``LANGUAGE`` are set to ``C``. * ``TZ`` is set to ``GMT``. * ``COLUMNS`` is set to ``80``. * ``CDPATH`` and ``GREP_OPTIONS`` are set to an empty string. Cram also provides the following environment variables to tests: * ``CRAMTMP``, set to the test runner's temporary directory. * ``TESTDIR``, set to the directory containing the test file. .. _unified context diff: https://en.wikipedia.org/wiki/Diff#Unified_format .. _its own example tests: https://bitbucket.org/brodie/cram/src/tip/examples/ News ---- Version 0.6 (Aug. 1, 2013) `````````````````````````` * Added the long option ``--preserve-env`` for ``-E``. * Added support for specifying options in ``.cramrc`` (configurable with the ``CRAMRC`` environment variable). * Added a ``--shell`` option to change the shell tests are run with. Contributed by `Kamil Kisiel`_. * Added Arch Linux package metadata (in ``contrib/``). Contributed by `Andrey Vlasovskikh`_. * Fixed shell commands unintentionally inheriting Python's ``SIGPIPE`` handler (causing commands that close pipes to print ``broken pipe`` messages). * Fixed ``EPIPE`` under PyPy when applying patches in ``--interactive`` mode. * Added ``TESTFILE`` test environment variable (set to the name of the current test). * Fixed GNU patch 2.7 compatibility by using relative paths instead of absolute paths. Contributed by `Douglas Creager`_. * Fixed name clashes in temporary test directories (e.g., when running two tests with the same name in different folders). * **Backwards compatibility:** Fixed improper usage of the subprocess library under Python 3. This fixes Python 3.3 support, but breaks support for Python 3.1-3.2.3 due to a bug in Python. If you're using Python 3.0-3.2, you must upgrade to Python 3.2.4 or newer. .. _Kamil Kisiel: http://kamilkisiel.net/ .. _Andrey Vlasovskikh: https://twitter.com/vlasovskikh .. _Douglas Creager: http://dcreager.net/ Version 0.5 (Jan. 8, 2011) `````````````````````````` * **The test format has changed:** Matching output not ending in a newline now requires the ``(no-eol)`` keyword instead of ending the line in ``%``. * Matching output containing unprintable characters now requires the ``(esc)`` keyword. Real output containing unprintable characters will automatically receive ``(esc)``. * If an expected line matches its real output line exactly, special matching like ``(re)`` or ``(glob)`` will be ignored. * Regular expressions ending in a trailing backslash are now considered invalid. * Added an ``--indent`` option for changing the default amount of indentation required to specify commands and output. * Added support for specifying command line options in the ``CRAM`` environment variable. * The ``--quiet`` and ``--verbose`` options can now be used together. * When running Cram under Python 3, Unicode-specific line break characters will no longer be parsed as newlines. * Tests are no longer required to end in a trailing newline. Version 0.4 (Sep. 28, 2010) ``````````````````````````` * **The test format has changed:** Output lines containing regular expressions must now end in ``(re)`` or they'll be matched literally. Lines ending with keywords are matched literally first, however. * Regular expressions are now matched from beginning to end. In other words ``\d (re)`` is matched as ``^\d$``. * In addition to ``(re)``, ``(glob)`` has been added. It supports ``*``, ``?``, and escaping both characters (and backslashes) using ``\``. * **Environment settings have changed:** The ``-D`` flag has been removed, ``$TESTDIR`` is now set to the directory containing the ``.t`` file, and ``$CRAMTMP`` is set to the test runner's temporary directory. * ``-i``/``--interactive`` now requires ``patch(1)``. Instead of ``.err`` files replacing ``.t`` files during merges, diffs are applied using ``patch(1)``. This prevents matching regular expressions and globs from getting clobbered. * Previous ``.err`` files are now removed when tests pass. * Cram now exits with return code ``1`` if any tests failed. * If a test exits with return code ``80``, it's considered a skipped a test. This is useful for intentionally disabling tests when they only work on certain platforms or in certain settings. * The number of tests, the number of skipped tests, and the number of failed tests are now printed after all tests are finished. * Added ``-q``/``--quiet`` to suppress diff output. * Added `contrib/cram.vim`_ syntax file for Vim. Contributed by `Steve Losh`_. .. _contrib/cram.vim: https://bitbucket.org/brodie/cram/src/tip/contrib/cram.vim .. _Steve Losh: http://stevelosh.com/ Version 0.3 (Sep. 20, 2010) ``````````````````````````` * Implemented resetting of common environment variables. This behavior can be disabled using the ``-E`` flag. * Changed the test runner to first make its own overall random temporary directory, make ``tmp`` inside of it and set ``TMPDIR``, etc. to its path, and run each test with a random temporary working directory inside of that. * Added ``--keep-tmpdir``. Temporary directories are named by test filename (along with a random string). * Added ``-i``/``--interactive`` to merge actual output back to into tests interactively. * Added ability to match command output not ending in a newline by suffixing output in the test with ``%``. Version 0.2 (Sep. 19, 2010) ``````````````````````````` * Changed the test runner to run tests with a random temporary working directory. Version 0.1 (Sep. 19, 2010) ``````````````````````````` * Initial release. Development ----------- Download the official development repository using Mercurial_:: hg clone https://bitbucket.org/brodie/cram Test Cram using Cram:: make tests Get a test coverage report using coverage.py_:: make coverage Visit Bitbucket_ if you'd like to fork the project, watch for new changes, or report issues. .. _Mercurial: http://mercurial.selenic.com/ .. _coverage.py: http://nedbatchelder.com/code/coverage/ .. _Bitbucket: https://bitbucket.org/brodie/cram Keywords: automatic functional test framework Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU General Public License (GPL) Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Unix Shell Classifier: Topic :: Software Development :: Testing cram-0.6/README.txt0000644000076500000240000002607212176557527014416 0ustar brodiestaff00000000000000====================== Cram: It's test time ====================== Cram is a functional testing framework for command line applications based on Mercurial_'s `unified test format`_. Cram tests look like snippets of interactive shell sessions. Cram runs each command and compares the command output in the test with the command's actual output. Here's a snippet from `Cram's own test suite`_:: The $PYTHON environment variable should be set when running this test from Python. $ [ -n "$PYTHON" ] || PYTHON="`which python`" $ if [ -n "$COVERAGE" ]; then > coverage erase > alias cram="`which coverage` run --branch -a $TESTDIR/../cram.py" > else > alias cram="$PYTHON $TESTDIR/../cram.py" > fi $ command -v md5 > /dev/null || alias md5=md5sum Usage: $ cram -h [Uu]sage: cram \[OPTIONS\] TESTS\.\.\. (re) [Oo]ptions: (re) -h, --help show this help message and exit -V, --version show version information and exit -q, --quiet don't print diffs -v, --verbose show filenames and test status -i, --interactive interactively merge changed test output -y, --yes answer yes to all questions -n, --no answer no to all questions -E, --preserve-env don't reset common environment variables --keep-tmpdir keep temporary directories --shell=PATH shell to use for running tests --indent=NUM number of spaces to use for indentation The format in a nutshell: * Cram tests use the ``.t`` file extension. * Lines beginning with two spaces, a dollar sign, and a space are run in the shell. * Lines beginning with two spaces, a greater than sign, and a space allow multi-line commands. * All other lines beginning with two spaces are considered command output. * Output lines ending with a space and the keyword ``(re)`` are matched as `Perl-compatible regular expressions`_. * Lines ending with a space and the keyword ``(glob)`` are matched with a glob-like syntax. The only special characters supported are ``*`` and ``?``. Both characters can be escaped using ``\``, and the backslash can be escaped itself. * Output lines ending with either of the above keywords are always first matched literally with actual command output. * Lines ending with a space and the keyword ``(no-eol)`` will match actual output that doesn't end in a newline. * Actual output lines containing unprintable characters are escaped and suffixed with a space and the keyword ``(esc)``. Lines matching unprintable output must also contain the keyword. * Anything else is a comment. .. _Mercurial: http://mercurial.selenic.com/ .. _unified test format: http://www.selenic.com/blog/?p=663 .. _Cram's own test suite: https://bitbucket.org/brodie/cram/src/tip/tests/cram.t .. _Perl-compatible regular expressions: https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions Download -------- * cram-0.6.tar.gz_ (24 KB, requires Python 2.4-2.7 or Python 3.1-3.2) .. _cram-0.6.tar.gz: https://bitheap.org/cram/cram-0.6.tar.gz Installation ------------ You can use pip_ to install Cram:: $ pip install cram Or you can install Cram using GNU make:: $ wget https://bitheap.org/cram/cram-0.6.tar.gz $ tar zxvf cram-0.6.tar.gz $ cd cram-0.6 $ make install .. _pip: https://pypi.python.org/pypi/pip Usage ----- Cram will print a dot for each passing test. If a test fails, a `unified context diff`_ is printed showing the test's expected output and the actual output. Skipped tests (empty tests and tests that exit with return code ``80``) are marked with ``s`` instead of a dot. For example, if we run Cram on `its own example tests`_:: .s.! --- /home/brodie/src/cram/examples/fail.t +++ /home/brodie/src/cram/examples/fail.t.err @@ -3,21 +3,22 @@ $ echo 1 1 $ echo 1 - 2 + 1 $ echo 1 1 Invalid regex: $ echo 1 - +++ (re) + 1 Offset regular expression: $ printf 'foo\nbar\nbaz\n\n1\nA\n@\n' foo + bar baz \d (re) [A-Z] (re) - # + @ s. # Ran 6 tests, 2 skipped, 1 failed. Cram will also write the test with its actual output to ``examples/fail.t.err``. When you're first writing a test, you might just write the commands and run the test to see what happens. If you run Cram with ``-i`` or ``--interactive``, you'll be prompted to merge the actual output back into the test. This makes it easy to quickly prototype new tests. You can specify a default set of options by creating a ``.cramrc`` file. For example:: [cram] verbose = True indent = 4 Is the same as invoking Cram with ``--verbose`` and ``--indent=4``. To change what configuration file Cram loads, you can set the ``CRAMRC`` environment variable. You can also specify command line options in the ``CRAM`` environment variable. Note that the following environment variables are reset before tests are run: * ``TMPDIR``, ``TEMP``, and ``TMP`` are set to the test runner's ``tmp`` directory. * ``LANG``, ``LC_ALL``, and ``LANGUAGE`` are set to ``C``. * ``TZ`` is set to ``GMT``. * ``COLUMNS`` is set to ``80``. * ``CDPATH`` and ``GREP_OPTIONS`` are set to an empty string. Cram also provides the following environment variables to tests: * ``CRAMTMP``, set to the test runner's temporary directory. * ``TESTDIR``, set to the directory containing the test file. .. _unified context diff: https://en.wikipedia.org/wiki/Diff#Unified_format .. _its own example tests: https://bitbucket.org/brodie/cram/src/tip/examples/ News ---- Version 0.6 (Aug. 1, 2013) `````````````````````````` * Added the long option ``--preserve-env`` for ``-E``. * Added support for specifying options in ``.cramrc`` (configurable with the ``CRAMRC`` environment variable). * Added a ``--shell`` option to change the shell tests are run with. Contributed by `Kamil Kisiel`_. * Added Arch Linux package metadata (in ``contrib/``). Contributed by `Andrey Vlasovskikh`_. * Fixed shell commands unintentionally inheriting Python's ``SIGPIPE`` handler (causing commands that close pipes to print ``broken pipe`` messages). * Fixed ``EPIPE`` under PyPy when applying patches in ``--interactive`` mode. * Added ``TESTFILE`` test environment variable (set to the name of the current test). * Fixed GNU patch 2.7 compatibility by using relative paths instead of absolute paths. Contributed by `Douglas Creager`_. * Fixed name clashes in temporary test directories (e.g., when running two tests with the same name in different folders). * **Backwards compatibility:** Fixed improper usage of the subprocess library under Python 3. This fixes Python 3.3 support, but breaks support for Python 3.1-3.2.3 due to a bug in Python. If you're using Python 3.0-3.2, you must upgrade to Python 3.2.4 or newer. .. _Kamil Kisiel: http://kamilkisiel.net/ .. _Andrey Vlasovskikh: https://twitter.com/vlasovskikh .. _Douglas Creager: http://dcreager.net/ Version 0.5 (Jan. 8, 2011) `````````````````````````` * **The test format has changed:** Matching output not ending in a newline now requires the ``(no-eol)`` keyword instead of ending the line in ``%``. * Matching output containing unprintable characters now requires the ``(esc)`` keyword. Real output containing unprintable characters will automatically receive ``(esc)``. * If an expected line matches its real output line exactly, special matching like ``(re)`` or ``(glob)`` will be ignored. * Regular expressions ending in a trailing backslash are now considered invalid. * Added an ``--indent`` option for changing the default amount of indentation required to specify commands and output. * Added support for specifying command line options in the ``CRAM`` environment variable. * The ``--quiet`` and ``--verbose`` options can now be used together. * When running Cram under Python 3, Unicode-specific line break characters will no longer be parsed as newlines. * Tests are no longer required to end in a trailing newline. Version 0.4 (Sep. 28, 2010) ``````````````````````````` * **The test format has changed:** Output lines containing regular expressions must now end in ``(re)`` or they'll be matched literally. Lines ending with keywords are matched literally first, however. * Regular expressions are now matched from beginning to end. In other words ``\d (re)`` is matched as ``^\d$``. * In addition to ``(re)``, ``(glob)`` has been added. It supports ``*``, ``?``, and escaping both characters (and backslashes) using ``\``. * **Environment settings have changed:** The ``-D`` flag has been removed, ``$TESTDIR`` is now set to the directory containing the ``.t`` file, and ``$CRAMTMP`` is set to the test runner's temporary directory. * ``-i``/``--interactive`` now requires ``patch(1)``. Instead of ``.err`` files replacing ``.t`` files during merges, diffs are applied using ``patch(1)``. This prevents matching regular expressions and globs from getting clobbered. * Previous ``.err`` files are now removed when tests pass. * Cram now exits with return code ``1`` if any tests failed. * If a test exits with return code ``80``, it's considered a skipped a test. This is useful for intentionally disabling tests when they only work on certain platforms or in certain settings. * The number of tests, the number of skipped tests, and the number of failed tests are now printed after all tests are finished. * Added ``-q``/``--quiet`` to suppress diff output. * Added `contrib/cram.vim`_ syntax file for Vim. Contributed by `Steve Losh`_. .. _contrib/cram.vim: https://bitbucket.org/brodie/cram/src/tip/contrib/cram.vim .. _Steve Losh: http://stevelosh.com/ Version 0.3 (Sep. 20, 2010) ``````````````````````````` * Implemented resetting of common environment variables. This behavior can be disabled using the ``-E`` flag. * Changed the test runner to first make its own overall random temporary directory, make ``tmp`` inside of it and set ``TMPDIR``, etc. to its path, and run each test with a random temporary working directory inside of that. * Added ``--keep-tmpdir``. Temporary directories are named by test filename (along with a random string). * Added ``-i``/``--interactive`` to merge actual output back to into tests interactively. * Added ability to match command output not ending in a newline by suffixing output in the test with ``%``. Version 0.2 (Sep. 19, 2010) ``````````````````````````` * Changed the test runner to run tests with a random temporary working directory. Version 0.1 (Sep. 19, 2010) ``````````````````````````` * Initial release. Development ----------- Download the official development repository using Mercurial_:: hg clone https://bitbucket.org/brodie/cram Test Cram using Cram:: make tests Get a test coverage report using coverage.py_:: make coverage Visit Bitbucket_ if you'd like to fork the project, watch for new changes, or report issues. .. _Mercurial: http://mercurial.selenic.com/ .. _coverage.py: http://nedbatchelder.com/code/coverage/ .. _Bitbucket: https://bitbucket.org/brodie/cram cram-0.6/scripts/0000755000076500000240000000000012176557607014377 5ustar brodiestaff00000000000000cram-0.6/scripts/cram0000755000076500000240000000011711445077455015242 0ustar brodiestaff00000000000000#!/usr/bin/env python import sys import cram sys.exit(cram.main(sys.argv[1:])) cram-0.6/setup.py0000755000076500000240000000406312176553263014422 0ustar brodiestaff00000000000000#!/usr/bin/env python """Installs cram""" import os import sys from distutils.core import setup, Command class test(Command): """Runs doctests and Cram tests""" description = 'run test suite' user_options = [('coverage', None, 'run tests using coverage.py')] def initialize_options(self): self.coverage = 0 def finalize_options(self): pass def run(self): import doctest import cram failures, tests = doctest.testmod(cram) sys.stdout.write('doctests: %s/%s passed\n' % (tests - failures, tests)) os.environ['PYTHON'] = sys.executable if self.coverage: # Note that when coverage.py is run, it uses the version # of Python it was installed with, NOT the version # setup.py was run with. os.environ['COVERAGE'] = '1' os.environ['COVERAGE_FILE'] = os.path.abspath('./.coverage') cram.main(['-v', 'tests']) def long_description(): """Get the long description from the README""" return open(os.path.join(sys.path[0], 'README.txt')).read() setup( author='Brodie Rao', author_email='brodie@bitheap.org', classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Console', 'Intended Audience :: Developers', 'License :: OSI Approved :: GNU General Public License (GPL)', 'Natural Language :: English', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Unix Shell', 'Topic :: Software Development :: Testing', ], cmdclass={'test': test}, description='A simple testing framework for command line applications', download_url='https://bitheap.org/cram/cram-0.6.tar.gz', keywords='automatic functional test framework', license='GNU GPL', long_description=long_description(), name='cram', py_modules=['cram'], scripts=['scripts/cram'], url='https://bitheap.org/cram/', version='0.6', ) cram-0.6/tests/0000755000076500000240000000000012176557607014052 5ustar brodiestaff00000000000000cram-0.6/tests/cram.t0000644000076500000240000002730012176553254015155 0ustar brodiestaff00000000000000The $PYTHON environment variable should be set when running this test from Python. $ [ "$0" != "/bin/bash" ] || shopt -s expand_aliases $ [ -n "$PYTHON" ] || PYTHON="`which python`" $ if [ -n "$COVERAGE" ]; then > coverage erase > alias cram="`which coverage` run --branch -a $TESTDIR/../cram.py" > else > alias cram="$PYTHON $TESTDIR/../cram.py" > fi $ command -v md5 > /dev/null || alias md5=md5sum Note: Bash doesn't expand aliases by default in non-interactive mode, so we enable it manually if the test is run with --shell=/bin/bash. Usage: $ cram -h [Uu]sage: cram \[OPTIONS\] TESTS\.\.\. (re) [Oo]ptions: (re) -h, --help show this help message and exit -V, --version show version information and exit -q, --quiet don't print diffs -v, --verbose show filenames and test status -i, --interactive interactively merge changed test output -y, --yes answer yes to all questions -n, --no answer no to all questions -E, --preserve-env don't reset common environment variables --keep-tmpdir keep temporary directories --shell=PATH shell to use for running tests --indent=NUM number of spaces to use for indentation $ cram -V Cram CLI testing framework (version 0.6) Copyright (C) 2010-2011 Brodie Rao and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ cram [Uu]sage: cram \[OPTIONS\] TESTS\.\.\. (re) [2] $ cram -y -n options -y and -n are mutually exclusive [2] $ cram non-existent also-not-here no such file: non-existent [2] Options in .cramrc: $ cat > .cramrc < [cram] > yes = True > no = 1 > indent = 4 > EOF $ cram options -y and -n are mutually exclusive [2] $ mv .cramrc config $ CRAMRC=config cram options -y and -n are mutually exclusive [2] $ rm config Invalid option in .cramrc: $ cat > .cramrc < [cram] > indent = hmm > EOF $ cram [Uu]sage: cram \[OPTIONS\] TESTS\.\.\. (re) cram: error: option --indent: invalid integer value: 'hmm' [2] $ rm .cramrc $ cat > .cramrc < [cram] > verbose = hmm > EOF $ cram [Uu]sage: cram \[OPTIONS\] TESTS\.\.\. (re) cram: error: --verbose: invalid boolean value: 'hmm' [2] $ rm .cramrc Options in an environment variable: $ CRAM='-y -n' cram options -y and -n are mutually exclusive [2] Copy in example tests: $ cp -R "$TESTDIR"/../examples . $ find . -name '*.err' -exec rm '{}' \; Run cram examples: $ cram -q examples examples/fail.t .s.!.s. # Ran 7 tests, 2 skipped, 1 failed. [1] $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm examples/fail.t.err Run examples with bash: $ cram --shell=/bin/bash -q examples examples/fail.t .s.!.s. # Ran 7 tests, 2 skipped, 1 failed. [1] $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm examples/fail.t.err Verbose mode: $ cram -q -v examples examples/fail.t examples/bare.t: passed examples/empty.t: empty examples/env.t: passed examples/fail.t: failed examples/missingeol.t: passed examples/skip.t: skipped examples/test.t: passed # Ran 7 tests, 2 skipped, 1 failed. [1] $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm examples/fail.t.err Interactive mode (don't merge): $ cram -n -i examples/fail.t ! --- fail.t +++ fail.t.err @@ -1,18 +1,18 @@ Output needing escaping: $ printf '\00\01\02\03\04\05\06\07\010\011\013\014\016\017\020\021\022\n' - foo + \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\x0b\x0c\x0e\x0f\x10\x11\x12 (esc) $ printf '\023\024\025\026\027\030\031\032\033\034\035\036\037\040\047\n' - bar + \x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ' (esc) Wrong output and bad regexes: $ echo 1 - 2 + 1 $ printf '1\nfoo\n1\n' - +++ (re) - foo\ (re) - (re) + 1 + foo + 1 Filler to force a second diff hunk: @@ -20,5 +20,6 @@ Offset regular expression: $ printf 'foo\n\n1\n' + foo \d (re) Accept this change? [yN] n # Ran 1 tests, 0 skipped, 1 failed. [1] $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) Interactive mode (merge): $ cp examples/fail.t examples/fail.t.orig $ cram -y -i examples/fail.t ! --- fail.t +++ fail.t.err @@ -1,18 +1,18 @@ Output needing escaping: $ printf '\00\01\02\03\04\05\06\07\010\011\013\014\016\017\020\021\022\n' - foo + \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\x0b\x0c\x0e\x0f\x10\x11\x12 (esc) $ printf '\023\024\025\026\027\030\031\032\033\034\035\036\037\040\047\n' - bar + \x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ' (esc) Wrong output and bad regexes: $ echo 1 - 2 + 1 $ printf '1\nfoo\n1\n' - +++ (re) - foo\ (re) - (re) + 1 + foo + 1 Filler to force a second diff hunk: @@ -20,5 +20,6 @@ Offset regular expression: $ printf 'foo\n\n1\n' + foo \d (re) Accept this change? [yN] y patching file fail.t # Ran 1 tests, 0 skipped, 1 failed. [1] $ md5 examples/fail.t .*\b1d9e5b527f01fbf2d9b1c121d005108c\b.* (re) $ mv examples/fail.t.orig examples/fail.t Verbose interactive mode (answer manually and don't merge): $ printf 'bad\nn\n' | cram -v -i examples/fail.t examples/fail.t: failed --- fail.t +++ fail.t.err @@ -1,18 +1,18 @@ Output needing escaping: $ printf '\00\01\02\03\04\05\06\07\010\011\013\014\016\017\020\021\022\n' - foo + \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\x0b\x0c\x0e\x0f\x10\x11\x12 (esc) $ printf '\023\024\025\026\027\030\031\032\033\034\035\036\037\040\047\n' - bar + \x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ' (esc) Wrong output and bad regexes: $ echo 1 - 2 + 1 $ printf '1\nfoo\n1\n' - +++ (re) - foo\ (re) - (re) + 1 + foo + 1 Filler to force a second diff hunk: @@ -20,5 +20,6 @@ Offset regular expression: $ printf 'foo\n\n1\n' + foo \d (re) Accept this change? [yN] Accept this change? [yN] # Ran 1 tests, 0 skipped, 1 failed. [1] $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ printf 'bad\n\n' | cram -v -i examples/fail.t examples/fail.t: failed --- fail.t +++ fail.t.err @@ -1,18 +1,18 @@ Output needing escaping: $ printf '\00\01\02\03\04\05\06\07\010\011\013\014\016\017\020\021\022\n' - foo + \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\x0b\x0c\x0e\x0f\x10\x11\x12 (esc) $ printf '\023\024\025\026\027\030\031\032\033\034\035\036\037\040\047\n' - bar + \x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ' (esc) Wrong output and bad regexes: $ echo 1 - 2 + 1 $ printf '1\nfoo\n1\n' - +++ (re) - foo\ (re) - (re) + 1 + foo + 1 Filler to force a second diff hunk: @@ -20,5 +20,6 @@ Offset regular expression: $ printf 'foo\n\n1\n' + foo \d (re) Accept this change? [yN] Accept this change? [yN] # Ran 1 tests, 0 skipped, 1 failed. [1] $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) Verbose interactive mode (answer manually and merge): $ cp examples/fail.t examples/fail.t.orig $ printf 'bad\ny\n' | cram -v -i examples/fail.t examples/fail.t: failed --- fail.t +++ fail.t.err @@ -1,18 +1,18 @@ Output needing escaping: $ printf '\00\01\02\03\04\05\06\07\010\011\013\014\016\017\020\021\022\n' - foo + \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\x0b\x0c\x0e\x0f\x10\x11\x12 (esc) $ printf '\023\024\025\026\027\030\031\032\033\034\035\036\037\040\047\n' - bar + \x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ' (esc) Wrong output and bad regexes: $ echo 1 - 2 + 1 $ printf '1\nfoo\n1\n' - +++ (re) - foo\ (re) - (re) + 1 + foo + 1 Filler to force a second diff hunk: @@ -20,5 +20,6 @@ Offset regular expression: $ printf 'foo\n\n1\n' + foo \d (re) Accept this change? [yN] Accept this change? [yN] patching file fail.t examples/fail.t: merged output # Ran 1 tests, 0 skipped, 1 failed. [1] $ md5 examples/fail.t .*\b1d9e5b527f01fbf2d9b1c121d005108c\b.* (re) $ mv examples/fail.t.orig examples/fail.t Test missing patch(1) and patch(1) error: $ PATH=. cram -i examples/fail.t patch(1) required for -i [2] $ cat > patch < #!/bin/sh > echo "patch failed" 1>&2 > exit 1 > EOF $ chmod +x patch $ PATH=. cram -y -i examples/fail.t ! --- fail.t +++ fail.t.err @@ -1,18 +1,18 @@ Output needing escaping: $ printf '\00\01\02\03\04\05\06\07\010\011\013\014\016\017\020\021\022\n' - foo + \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\x0b\x0c\x0e\x0f\x10\x11\x12 (esc) $ printf '\023\024\025\026\027\030\031\032\033\034\035\036\037\040\047\n' - bar + \x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ' (esc) Wrong output and bad regexes: $ echo 1 - 2 + 1 $ printf '1\nfoo\n1\n' - +++ (re) - foo\ (re) - (re) + 1 + foo + 1 Filler to force a second diff hunk: @@ -20,5 +20,6 @@ Offset regular expression: $ printf 'foo\n\n1\n' + foo \d (re) Accept this change? [yN] y patch failed examples/fail.t: merge failed # Ran 1 tests, 0 skipped, 1 failed. [1] $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm patch examples/fail.t.err Test that a fixed .err file is deleted: $ echo " $ echo 1" > fixed.t $ cram fixed.t ! --- fixed.t +++ fixed.t.err @@ -1,1 +1,2 @@ $ echo 1 + 1 # Ran 1 tests, 0 skipped, 1 failed. [1] $ cp fixed.t.err fixed.t $ cram fixed.t . # Ran 1 tests, 0 skipped, 0 failed. $ test \! -f fixed.t.err $ rm fixed.t Don't sterilize environment: $ TZ=foo; export TZ $ CDPATH=foo; export CDPATH $ COLUMNS=42; export COLUMNS $ GREP_OPTIONS=foo; export GREP_OPTIONS $ cram -E examples/env.t ! \-\-\- env\.t\s* (re) \+\+\+ env\.t\.err\s* (re) @@ -7,13 +7,13 @@ $ echo "$LANGUAGE" C $ echo "$TZ" - GMT + foo $ echo "$CDPATH" - + foo $ echo "$COLUMNS" - 80 + 42 $ echo "$GREP_OPTIONS" - + foo $ echo "$CRAMTMP" .+ (re) $ echo "$TESTDIR" # Ran 1 tests, 0 skipped, 1 failed. [1] $ rm examples/env.t.err Note: We can't set the locale to foo because some shells will issue warnings for invalid locales. Test --keep-tmpdir: $ cram -q --keep-tmpdir examples/test.t | while read line; do > echo "$line" 1>&2 > msg=`echo "$line" | cut -d ' ' -f 1-4` > if [ "$msg" = '# Kept temporary directory:' ]; then > echo "$line" | cut -d ' ' -f 5 > fi > done > keeptmp . # Ran 1 tests, 0 skipped, 0 failed. # Kept temporary directory: */cramtests-* (glob) $ ls "`cat keeptmp`" | sort test.t tmp Custom indentation: $ cat > indent.t < Indented by 4 spaces: > > $ echo foo > foo > > Not part of the test: > > $ echo foo > bar > EOF $ cram --indent=4 indent.t . # Ran 1 tests, 0 skipped, 0 failed. cram-0.6/TODO.txt0000644000076500000240000000147511450272351014205 0ustar brodiestaff00000000000000* Implement -j flag, most likely using spawnv(). * Using spawnv() machinery, implement distributed testing. * Be able to run the Mercurial test suite. * Write cram plugins for other testing frameworks (nose, py.test, etc.). * Windows support. * Ability to specify test options/metadata inside a test. * Setup/teardown support. * Coverage integration. * unittest integration. * Support #!/usr/bin/env cram * Two kinds of setup/teardown: for all tests or a group of tests, and for each test. * Emacs mode. * If a specific file is specified, it should be run even if it doesn't end .t (for tests embedded in docs). This might require making the indentation more flexible. * On that note, make it possible to specify tests in Python doc strings (and similar things in other languages like Perl, Ruby, etc.).