From: Magnus Jacobsson Date: Mon, 6 Jul 2020 17:22:57 +0000 (+0200) Subject: Adapt test_examples.py to Windows X-Git-Tag: 2.46.0~20^2^2~192^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e55960680200fa70990fc543ab97875473f8383c;p=graphviz Adapt test_examples.py to Windows --- diff --git a/rtest/test_examples.py b/rtest/test_examples.py index 21c9fa23b..3e6f4da20 100644 --- a/rtest/test_examples.py +++ b/rtest/test_examples.py @@ -7,18 +7,16 @@ import subprocess def c_compiler(): '''find the system's C compiler''' - return os.environ.get('CC', 'cc') + if platform.system() == 'Windows': + return "cl" + else: + return os.environ.get('CC', 'cc') @pytest.mark.parametrize('src', ['demo.c', 'dot.c', 'example.c', 'neatopack.c', 'simple.c']) def test_compile_example(src): '''try to compile the example''' - # FIXME: if you know how to call the C compiler on Windows, please implement - # this functionality - if platform.system() == 'Windows': - pytest.skip('not implemented for Windows') - # construct an absolute path to the example filepath = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../dot.demo', src) @@ -28,5 +26,9 @@ def test_compile_example(src): libs = ('cgraph', 'gvc') # ensure the C compiler can build this without error - subprocess.check_call([cc, '-o', os.devnull, filepath] - + ['-l{}'.format(l) for l in libs]) + if platform.system() == 'Windows': + subprocess.check_call([cc, filepath, '-nologo', '-link'] + + ['{}.lib'.format(l) for l in libs]) + else: + subprocess.check_call([cc, '-o', os.devnull, filepath] + + ['-l{}'.format(l) for l in libs])