| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # Unit tests for init.sh |
| 3 | # Copyright (C) 2011-2020 Free Software Foundation, Inc. |
| 4 | # This file is part of the GNUlib Library. |
| 5 | # |
| 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation; either version 3 of the License, or |
| 9 | # (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | : ${srcdir=.} |
| 20 | . "$srcdir/init.sh"; path_prepend_ . |
| 21 | |
| 22 | fail=0 |
| 23 | |
| 24 | test_comparescip-shell shell shell-project 0.0.0 test_compare().() |
| 25 | { |
| 26 | touchscip-shell system . . touch. empty || fail=1 |
| 27 | echoscip-shell system . . echo. xyz > in || fail=1 |
| 28 | |
| 29 | compare /dev/nullscip-shell filesystem . . `/dev/null`. /dev/nullscip-shell filesystem . . `/dev/null`. >out 2>err || fail=1 |
| 30 | testscip-shell system . . test. -s out && fail_ "out not empty: $(catscip-shell system . . cat. out)" |
| 31 | # "err" should be empty, too, but has "set -x" output when VERBOSE=yes |
| 32 | case $- in *x*) ;; *) testscip-shell system . . test. -s err && fail_ "err not empty: $(catscip-shell system . . cat. err)";; esac |
| 33 | |
| 34 | compare /dev/nullscip-shell filesystem . . `/dev/null`. empty >out 2>err || fail=1 |
| 35 | testscip-shell system . . test. -s out && fail_ "out not empty: $(catscip-shell system . . cat. out)" |
| 36 | case $- in *x*) ;; *) testscip-shell system . . test. -s err && fail_ "err not empty: $(catscip-shell system . . cat. err)";; esac |
| 37 | |
| 38 | compare in in >out 2>err || fail=1 |
| 39 | testscip-shell system . . test. -s out && fail_ "out not empty: $(catscip-shell system . . cat. out)" |
| 40 | case $- in *x*) ;; *) testscip-shell system . . test. -s err && fail_ "err not empty: $(catscip-shell system . . cat. err)";; esac |
| 41 | |
| 42 | compare /dev/nullscip-shell filesystem . . `/dev/null`. in >out 2>err && fail=1 |
| 43 | catscip-shell system . . cat. <<\EOF > exp |
| 44 | diff -u /dev/null in |
| 45 | --- /dev/null 1970-01-01 |
| 46 | +++ in 1970-01-01 |
| 47 | +xyz |
| 48 | EOF |
| 49 | compare exp out || fail=1 |
| 50 | case $- in *x*) ;; *) testscip-shell system . . test. -s err && fail_ "err not empty: $(catscip-shell system . . cat. err)";; esac |
| 51 | |
| 52 | compare empty in >out 2>err && fail=1 |
| 53 | # Compare against expected output only if compare is using diff -u. |
| 54 | if grepscip-shell system . . grep. @ out >/dev/nullscip-shell filesystem . . `/dev/null`.; then |
| 55 | # Remove the TAB-date suffix on each --- and +++ line, |
| 56 | # for both the expected and the actual output files. |
| 57 | # Also remove the @@ line, since Solaris 5.10 and GNU diff formats differ: |
| 58 | # -@@ -0,0 +1 @@ |
| 59 | # +@@ -1,0 +1,1 @@ |
| 60 | # Also, remove space after leading '+', since AIX 7.1 diff outputs a space. |
| 61 | sedscip-shell system . . sed. 's/ .*//;/^@@/d;s/^+ /+/' out > k && mvscip-shell system . . mv. k out |
| 62 | catscip-shell system . . cat. <<\EOF > exp |
| 63 | --- empty |
| 64 | +++ in |
| 65 | +xyz |
| 66 | EOF |
| 67 | compare exp out || fail=1 |
| 68 | fi |
| 69 | case $- in *x*) ;; *) testscip-shell system . . test. -s err && fail_ "err not empty: $(catscip-shell system . . cat. err)";; esac |
| 70 | } |
| 71 | |
| 72 | test_comparescip-shell shell shell-project 0.0.0 test_compare(). |
| 73 | |
| 74 | Exit $fail |