Commits

Brodie Rao committed e349ae7

Added exit code 80 test skipping support

Comments (0)

Files changed (5)

 
 * 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.
+
 * Added ``-q``/``--quiet`` to suppress diff output.
 
 * The number of tests, the number of skipped tests, and the number of
 
 * Setup/teardown support.
 
-* hghave-like capability (exit 80 -> skipped).
-
 * Coverage integration.
 
 * unittest integration.
         (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 [].
     """
     f = open(path)
     abspath = os.path.abspath(path)
             after.setdefault(pos, []).append(line)
     p.stdin.write('echo "\n%s %s $?"\n' % (salt, i + 1))
 
+    output = p.communicate()[0]
+    if p.returncode == 80:
+        return (refout, None, [])
+
     pos = -1
     ret = 0
-    for i, line in enumerate(p.communicate()[0].splitlines(True)):
+    for i, line in enumerate(output.splitlines(True)):
         if line.startswith(salt):
             presalt = postout.pop()
             if presalt != '  \n':
                         shutil.rmtree(tmpdir)
 
             errpath = abspath + '.err'
-            if not diff:
+            if not postout:
+                skipped += 1
+                log('s', 'skipped\n', verbose)
+            elif not diff:
                 log('.', 'passed\n', verbose)
                 if os.path.exists(errpath):
                     os.remove(errpath)
   empty.t
   env.t
   fail.t
+  skip.t
   test.t
   $ pwd
   */cramtests*/env.t (glob)
      [A-Z] (re)
   -  #
   +  @
-  .
-  # Ran 5 tests, 1 skipped, 1 failed.
+  s.
+  # Ran 6 tests, 2 skipped, 1 failed.
   [1]
   $ md5 examples/fail.t examples/fail.t.err
   .*\ba36d8e81925296ce794f1a3b35994a68\b.* (re)
      [A-Z] (re)
   -  #
   +  @
+  examples/skip.t: skipped
   examples/test.t: passed
-  # Ran 5 tests, 1 skipped, 1 failed.
+  # Ran 6 tests, 2 skipped, 1 failed.
   [1]
   $ md5 examples/fail.t examples/fail.t.err
   .*\ba36d8e81925296ce794f1a3b35994a68\b.* (re)