(tmpdir)
| 445 | |
| 446 | |
| 447 | def test_platform_lookup_path(tmpdir): |
| 448 | test_file = os.path.join(tmpdir, 'test.c') |
| 449 | with open(test_file, 'wt'): |
| 450 | pass |
| 451 | |
| 452 | cppcheck = 'cppcheck' # No path |
| 453 | path = os.path.dirname(__lookup_cppcheck_exe()) |
| 454 | env = os.environ.copy() |
| 455 | env['PATH'] = path |
| 456 | exitcode, stdout, stderr, _ = cppcheck_ex(args=['--debug-lookup=platform', '--platform=avr8.xml', test_file], cppcheck_exe=cppcheck, cwd=str(tmpdir), env=env) |
| 457 | assert exitcode == 0, stdout if stdout else stderr |
| 458 | def format_path(p): |
| 459 | return p.replace('\\', '/').replace('"', '\'') |
| 460 | def try_fail(f): |
| 461 | f = format_path(f) |
| 462 | return "try to load platform file '{}' ... Error=XML_ERROR_FILE_NOT_FOUND ErrorID=3 (0x3) Line number=0: filename={}".format(f, f) |
| 463 | def try_success(f): |
| 464 | f = format_path(f) |
| 465 | return "try to load platform file '{}' ... Success".format(f) |
| 466 | lines = stdout.replace('\\', '/').replace('"', '\'').splitlines() |
| 467 | assert lines == [ |
| 468 | "looking for platform 'avr8.xml'", |
| 469 | try_fail(os.path.join(tmpdir, 'avr8.xml')), |
| 470 | try_fail(os.path.join(tmpdir, 'platforms', 'avr8.xml')), |
| 471 | try_fail(os.path.join(path, 'avr8.xml')), |
| 472 | try_success(os.path.join(path, 'platforms', 'avr8.xml')), |
| 473 | 'Checking {} ...'.format(format_path(test_file)) |
| 474 | ] |
| 475 | |
| 476 | |
| 477 | def test_platform_lookup_notfound(tmpdir): |
nothing calls this directly
no test coverage detected