def test_invoke_compiler_success(): "Test that warnings are propagated" warn_file = Path('tests/pkg1/warn.nim').resolve() out_file = Path('tests/pkg1/warn' + NimCompiler.EXT).resolve() try: # Since we are full-on invoking the compiler for a working build here, # we gotta make sure it has the same flags as normal (for win32, etc.) # This also means Nimpy has to be installed prior to building. NimCompiler.ensure_nimpy() out, err, war, hin = NimCompiler.invoke_compiler([ 'nim', 'c', *NimCompiler.NIM_CLI_ARGS, f'--out:{out_file}', str(warn_file) ]) assert out_file.exists(), err assert any("Warning: imported and not used: 'asyncstreams'" in i for i in war) assert any('Hint' in i for i in hin) finally: if out_file.exists(): out_file.unlink() if sys.platform == 'win32': warn_exp = Path('tests/pkg1/warn.exp') warn_lib = Path('tests/pkg1/warn.lib') if warn_exp.exists(): warn_exp.unlink() if warn_lib.exists(): warn_lib.unlink()
def test_ensure_nimpy(): "Make sure that the Nimpy library can be installed." assert shutil.which('nim'), 'Nim compiler is not installed or not on path' # Make sure it is not installed out = NimCompiler.invoke_compiler('nimble path nimpy'.split()) # Remove it if out[1]: out = NimCompiler.invoke_compiler( 'nimble uninstall nimpy --accept'.split()) # Install/verify it is already installed NimCompiler.ensure_nimpy() # Check installation code path NimCompiler.ensure_nimpy() # Verify that it is actuall installed according to Nimble out = NimCompiler.invoke_compiler('nimble path nimpy'.split()) assert out[0] and not out[1]