1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
Set up cram alias and example tests:
$ . "$TESTDIR"/setup.sh
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
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
$ GREP_OPTIONS=foo; export GREP_OPTIONS
$ cram -E examples/env.t
!
\-\-\- examples/env\.t\s* (re)
\+\+\+ examples/env\.t\.err\s* (re)
@@ -7,11 +7,11 @@
$ echo "$LANGUAGE"
C
$ echo "$TZ"
- GMT
+ foo
$ echo "$CDPATH"
-
+ foo
$ 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 <<EOF
> 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.
Test running tests with the same filename in different directories:
$ mkdir subdir1 subdir2
$ cat > subdir1/test.t <<EOF
> $ echo 1
> EOF
$ cat > subdir2/test.t <<EOF
> $ echo 2
> EOF
$ cram subdir1 subdir2
!
--- subdir1/test.t
+++ subdir1/test.t.err
@@ -1,1 +1,2 @@
$ echo 1
+ 1
!
--- subdir2/test.t
+++ subdir2/test.t.err
@@ -1,1 +1,2 @@
$ echo 2
+ 2
# Ran 2 tests, 0 skipped, 2 failed.
[1]
|