aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/test.fish
blob: 2b796ef8d700716d2de5519a008f8b8b589ac694 (plain)
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
#!/usr/local/bin/fish
#
# Main loop of the test suite. I wrote this
# instad of using autotest to provide additional
# testing for fish. :-)


if [ "$argv" != '-n' ]
  # begin...end has bug in error redirecting...
  begin
    ../fish -n ./test.fish ^top.tmp.err
    ../fish -n ./test.fish -n ^^top.tmp.err
    ../fish ./test.fish -n ^^top.tmp.err
  end | tee top.tmp.out
  echo $status >top.tmp.status
  set res ok
  if diff top.tmp.out top.out >/dev/null
  else
	set res fail
	echo Output differs for file test.fish
  end

  if diff top.tmp.err top.err >/dev/null
  else
	set res fail
	echo Error output differs for file test.fish
  end

  if test (cat top.tmp.status) = (cat top.status)
  else
	set res fail
	echo Exit status differs for file test.fish
  end

  ../fish -p /dev/null -c 'echo testing' >/dev/null
  if test $status -ne 0
	set res fail
	echo Profiling fails
  end

  if test $res = ok;
	echo File test.fish tested ok
        exit 0
  else
	echo File test.fish failed tests
        exit 1
  end;
end

echo Testing high level script functionality

for i in *.in
  set template_out (basename $i .in).out
  set template_err (basename $i .in).err
  set template_status (basename $i .in).status

  ../fish <$i >tmp.out ^tmp.err
  echo $status >tmp.status
  set res ok
  if diff tmp.out $template_out >/dev/null
  else
	set res fail
	echo Output differs for file $i
  end

  if diff tmp.err $template_err >/dev/null
  else
	set res fail
	echo Error output differs for file $i
  end

  if test (cat tmp.status) = (cat $template_status)
  else
	set res fail
	echo Exit status differs for file $i
  end

  if test $res = ok;
	echo File $i tested ok
  else
	echo File $i failed tests
  end;

end