Skip to content

Commit e138186

Browse files
committed
integration_test.py: added tests for missing files
1 parent bc7bbb8 commit e138186

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

integration_test.py

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,151 @@ def test_pragma_once_matching(record_property, tmpdir):
298298

299299
assert stdout.count("ONCE") == 1
300300
assert stderr == ""
301+
302+
303+
def test_input_multiple(record_property, tmpdir):
304+
test_file = os.path.join(tmpdir, "test.c")
305+
with open(test_file, 'w'):
306+
pass
307+
308+
test_file_1 = os.path.join(tmpdir, "test1.c")
309+
with open(test_file_1, 'w'):
310+
pass
311+
312+
args = [
313+
'test.c',
314+
'test1.c'
315+
]
316+
317+
_, stdout, stderr = simplecpp(args, cwd=tmpdir)
318+
record_property("stdout", stdout)
319+
record_property("stderr", stderr)
320+
321+
assert '' == stderr
322+
assert "error: multiple filenames specified\n" == stdout
323+
324+
325+
def test_input_missing(record_property, tmpdir):
326+
args = [
327+
'missing.c'
328+
]
329+
330+
_, stdout, stderr = simplecpp(args, cwd=tmpdir)
331+
record_property("stdout", stdout)
332+
record_property("stderr", stderr)
333+
334+
assert '' == stderr
335+
assert "error: could not open file 'missing.c'\n" == stdout
336+
337+
338+
def test_input_dir(record_property, tmpdir):
339+
test_dir = os.path.join(tmpdir, "test")
340+
os.mkdir(test_dir)
341+
342+
args = [
343+
'test'
344+
]
345+
346+
_, stdout, stderr = simplecpp(args, cwd=tmpdir)
347+
record_property("stdout", stdout)
348+
record_property("stderr", stderr)
349+
350+
assert '' == stderr
351+
assert "error: could not open file 'test'\n" == stdout
352+
353+
354+
def test_incpath_missing(record_property, tmpdir):
355+
test_file = os.path.join(tmpdir, "test.c")
356+
with open(test_file, 'w'):
357+
pass
358+
359+
test_dir = os.path.join(tmpdir, "test")
360+
os.mkdir(test_dir)
361+
362+
args = [
363+
'-Itest',
364+
'-Imissing',
365+
'test.c'
366+
]
367+
368+
_, stdout, stderr = simplecpp(args, cwd=tmpdir)
369+
record_property("stdout", stdout)
370+
record_property("stderr", stderr)
371+
372+
assert '' == stderr
373+
assert "error: could not find include path 'missing'\n" == stdout
374+
375+
376+
def test_incpath_file(record_property, tmpdir):
377+
test_file = os.path.join(tmpdir, "test.c")
378+
with open(test_file, 'w'):
379+
pass
380+
381+
inc_dir = os.path.join(tmpdir, "inc")
382+
os.mkdir(inc_dir)
383+
384+
inc_file = os.path.join(tmpdir, "inc.h")
385+
with open(test_file, 'w'):
386+
pass
387+
388+
args = [
389+
'-Iinc',
390+
'-Iinc.h',
391+
'test.c'
392+
]
393+
394+
_, stdout, stderr = simplecpp(args, cwd=tmpdir)
395+
record_property("stdout", stdout)
396+
record_property("stderr", stderr)
397+
398+
assert '' == stderr
399+
assert "error: could not find include path 'inc.h'\n" == stdout
400+
401+
402+
def test_incfile_missing(record_property, tmpdir):
403+
test_file = os.path.join(tmpdir, "test.c")
404+
with open(test_file, 'w'):
405+
pass
406+
407+
inc_file = os.path.join(tmpdir, "inc.h")
408+
with open(inc_file, 'w'):
409+
pass
410+
411+
args = [
412+
'-include=inc.h',
413+
'-include=missing.h',
414+
'test.c'
415+
]
416+
417+
_, stdout, stderr = simplecpp(args, cwd=tmpdir)
418+
record_property("stdout", stdout)
419+
record_property("stderr", stderr)
420+
421+
assert '' == stderr
422+
assert "error: could not open include 'missing.h'\n" == stdout
423+
424+
425+
def test_incpath_dir(record_property, tmpdir):
426+
test_file = os.path.join(tmpdir, "test.c")
427+
with open(test_file, 'w'):
428+
pass
429+
430+
inc_file = os.path.join(tmpdir, "inc.h")
431+
with open(inc_file, 'w'):
432+
pass
433+
434+
inc_dir = os.path.join(tmpdir, "inc")
435+
os.mkdir(inc_dir)
436+
437+
args = [
438+
'-include=inc.h',
439+
'-include=inc',
440+
'test.c'
441+
]
442+
443+
_, stdout, stderr = simplecpp(args, cwd=tmpdir)
444+
record_property("stdout", stdout)
445+
record_property("stderr", stderr)
446+
447+
assert '' == stderr
448+
assert "error: could not open include 'inc'\n" == stdout

0 commit comments

Comments
 (0)