44619dce882188feec706e256488266a328228e0
[ghc.git] / libraries / base / tests / IO / all.T
1 # -*- coding: utf-8 -*-
2
3 def expect_fail_if_windows(name, opts):
4    f = when(opsys('mingw32'), expect_fail);
5    return f(normal, opts);
6
7 test('IOError001', [omit_ways(['ghci']), set_stdin('IOError001.hs')],
8         compile_and_run, [''])
9
10 test('IOError002',      normal, compile_and_run, [''])
11 test('finalization001', normal, compile_and_run, [''])
12 test('hClose001',       extra_clean(['hClose001.tmp']), compile_and_run, [''])
13 test('hClose002',       extra_clean(['hClose002.tmp']), compile_and_run, [''])
14 test('hClose003',       reqlib('unix'), compile_and_run, ['-package unix'])
15 test('hFileSize001',    normal, compile_and_run, [''])
16 test('hFileSize002',
17      [omit_ways(['ghci']),
18       extra_clean(['hFileSize002.out'])],
19      compile_and_run, [''])
20 test('hFlush001',
21      extra_clean(['hFlush001.out']),
22      compile_and_run, [''])
23
24 test('hGetBuffering001', 
25         [omit_ways(['ghci']), set_stdin('hGetBuffering001.hs')], 
26         compile_and_run, [''])
27
28 test('hGetChar001', normal, compile_and_run, [''])
29 test('hGetLine001', set_stdin('hGetLine001.hs'), compile_and_run, ['-cpp'])
30 test('hGetLine002', normal, compile_and_run, [''])
31 test('hGetLine003', normal, compile_and_run, [''])
32 test('hGetPosn001',
33      extra_clean(['hGetPosn001.out']),
34      compile_and_run, ['-cpp'])
35 test('hIsEOF001',   normal, compile_and_run, [''])
36 test('hIsEOF002', extra_clean(['hIsEOF002.out']), compile_and_run, ['-cpp'])
37
38 test('hReady001', normal, compile_and_run, ['-cpp'])
39
40 # hReady002 tests that hReady returns False for a pipe that has no
41 # data to read.  It relies on piping input from 'sleep 1', which doesn't
42 # work for the 'ghci' way because in that case we already pipe input from
43 # a script, so hence omit_ways(['ghci'])
44 test('hReady002', [cmd_prefix('sleep 1 |'), omit_ways(['ghci'])],
45      compile_and_run, [''])
46
47 test('hSeek001', normal, compile_and_run, [''])
48 test('hSeek002', normal, compile_and_run, ['-cpp'])
49 test('hSeek003', normal, compile_and_run, ['-cpp'])
50 test('hSeek004', extra_clean(['hSeek004.out']), compile_and_run, ['-cpp'])
51
52 test('hSetBuffering002', set_stdin('hSetBuffering002.hs'), compile_and_run, [''])
53
54 test('hSetBuffering003',
55     [omit_ways(['ghci']), set_stdin('hSetBuffering003.hs')], 
56         compile_and_run, [''])
57
58 test('hSetBuffering004', set_stdin('hSetBuffering004.hs'), compile_and_run, [''])
59
60 test('ioeGetErrorString001', normal, compile_and_run, ['-cpp'])
61 test('ioeGetFileName001',    normal, compile_and_run, ['-cpp'])
62 test('ioeGetHandle001',      normal, compile_and_run, ['-cpp'])
63 test('isEOF001', extra_run_opts('</dev/null'), compile_and_run, [''])
64
65 test('misc001',
66      [extra_run_opts('misc001.hs misc001.out'),
67       extra_clean(['misc001.out'])],
68         compile_and_run, [''])
69
70 test('openFile001',  normal, compile_and_run, [''])
71 test('openFile002',  exit_code(1), compile_and_run, [''])
72 test('openFile003',  extra_clean(['openFile003Dir']), compile_and_run, [''])
73 test('openFile004',  extra_clean(['openFile004.out']), compile_and_run, [''])
74 test('openFile005',  extra_clean(['openFile005.out1', 'openFile005.out2']),
75      compile_and_run, [''])
76 test('openFile006', extra_clean(['openFile006.out']), compile_and_run, [''])
77 test('openFile007', extra_clean(['openFile007.out']), compile_and_run, [''])
78 test('openFile008', cmd_prefix('ulimit -n 2048; '), compile_and_run, [''])
79
80 test('putStr001',    normal, compile_and_run, [''])
81 test('readFile001',  extra_clean(['readFile001.out']),
82      compile_and_run, [''])
83 test('readwrite001',
84      extra_clean(['readwrite001.inout']),
85      compile_and_run,
86      ['-cpp'])
87
88
89 test('readwrite002',
90      [omit_ways(['ghci']), 
91       set_stdin('readwrite002.hs'),
92       extra_clean(['readwrite002.inout'])],
93      compile_and_run, ['-cpp'])
94
95 test('readwrite003', extra_clean(['readwrite003.txt']), compile_and_run, [''])
96
97 test('hGetBuf001',
98      [
99       when(fast(), skip),
100       expect_fail_if_windows],
101      compile_and_run, ['-package unix'])
102
103 test('hDuplicateTo001', extra_clean(['tmp']), compile_and_run, [''])
104
105 test('countReaders001',
106       extra_clean(['countReaders001.txt']),
107       compile_and_run, [''])
108
109 test('concio001', normal, run_command, ['$MAKE -s --no-print-directory test.concio001'])
110 test('concio001.thr', normal, run_command, ['$MAKE -s --no-print-directory test.concio001.thr'])
111
112 test('concio002', reqlib('process'), compile_and_run, [''])
113
114 test('T2122', extra_clean(['T2122-test']), compile_and_run, [''])
115 test('T3307',
116      [extra_clean(['chinese-file-小说', 'chinese-name'])],
117      run_command,
118      ['$MAKE -s --no-print-directory T3307-test'])
119 test('T4855', normal, compile_and_run, [''])
120
121 test('hSetEncoding001',extra_run_opts('hSetEncoding001.in'), compile_and_run, [''])
122 test('decodingerror001',normal, compile_and_run, [''])
123 test('decodingerror002',normal, compile_and_run, [''])
124
125 encoding001Encodings = ["utf8", "utf8_bom", "utf16", "utf16le",
126                         "utf16be", "utf32", "utf32le", "utf32be"]
127 encoding001CleanFiles = []
128 for e in encoding001Encodings:
129     encoding001CleanFiles.append('encoding001.' + e)
130 for e1 in encoding001Encodings:
131     for e2 in encoding001Encodings:
132         encoding001CleanFiles.append('encoding001.' + e1 + '.' + e2)
133 test('encoding001',
134      extra_clean(encoding001CleanFiles),
135      compile_and_run, [''])
136
137 test('encoding002', normal, compile_and_run, [''])
138 test('encoding003', normal, compile_and_run, [''])
139 test('encoding004', normal, compile_and_run, [''])
140 test('encoding005', normal, compile_and_run, [''])
141
142 test('environment001',
143      [extra_clean(['environment001'])],
144      run_command,
145      ['$MAKE -s --no-print-directory environment001-test'])
146
147 test('newline001', extra_clean(['newline001.out']), compile_and_run, [''])
148
149 test('openTempFile001', normal, compile_and_run, [''])
150
151 test('T4144', normal, compile_and_run, [''])
152
153 test('encodingerror001', normal, compile_and_run, [''])
154
155 test('T4808', [exit_code(1), extra_clean(['T4808.test'])], compile_and_run, [''])
156 test('T4895', normal, compile_and_run, [''])
157 test('T7853', normal, compile_and_run, [''])