-import atexit
import pytest
import platform
-import shutil
import signal
import subprocess
import os
assert os.path.exists(c_src), 'missing test case'
# create some scratch space to work in
- tmp = tempfile.mkdtemp()
- atexit.register(shutil.rmtree, tmp)
-
- # compile our test code
- exe = os.path.join(tmp, 'a.exe')
- rt_lib_option = '-MDd' if os.environ.get('configuration') == 'Debug' else '-MD'
-
- if platform.system() == 'Windows':
- subprocess.check_call(['cl', c_src, '-Fe:', exe, '-nologo',
- rt_lib_option, '-link', 'cgraph.lib', 'gvc.lib'])
- else:
- cc = os.environ.get('CC', 'cc')
- subprocess.check_call([cc, c_src, '-o', exe, '-lcgraph', '-lgvc'])
-
- # find our co-located dot input
- dot = os.path.abspath(os.path.join(os.path.dirname(__file__), '1767.dot'))
- assert os.path.exists(dot), 'missing test case'
-
- # run the test
- stdout = subprocess.check_output([exe, dot], universal_newlines=True)
-
- assert stdout == 'Loaded graph:clusters\n' \
- 'cluster_0 contains 5 nodes\n' \
- 'cluster_1 contains 1 nodes\n' \
- 'cluster_2 contains 3 nodes\n' \
- 'cluster_3 contains 3 nodes\n' \
- 'Loaded graph:clusters\n' \
- 'cluster_0 contains 5 nodes\n' \
- 'cluster_1 contains 1 nodes\n' \
- 'cluster_2 contains 3 nodes\n' \
- 'cluster_3 contains 3 nodes\n'
+ with tempfile.TemporaryDirectory() as tmp:
+
+ # compile our test code
+ exe = os.path.join(tmp, 'a.exe')
+ rt_lib_option = '-MDd' if os.environ.get('configuration') == 'Debug' else '-MD'
+
+ if platform.system() == 'Windows':
+ subprocess.check_call(['cl', c_src, '-Fe:', exe, '-nologo',
+ rt_lib_option, '-link', 'cgraph.lib', 'gvc.lib'])
+ else:
+ cc = os.environ.get('CC', 'cc')
+ subprocess.check_call([cc, c_src, '-o', exe, '-lcgraph', '-lgvc'])
+
+ # find our co-located dot input
+ dot = os.path.abspath(os.path.join(os.path.dirname(__file__), '1767.dot'))
+ assert os.path.exists(dot), 'missing test case'
+
+ # run the test
+ stdout = subprocess.check_output([exe, dot], universal_newlines=True)
+
+ assert stdout == 'Loaded graph:clusters\n' \
+ 'cluster_0 contains 5 nodes\n' \
+ 'cluster_1 contains 1 nodes\n' \
+ 'cluster_2 contains 3 nodes\n' \
+ 'cluster_3 contains 3 nodes\n' \
+ 'Loaded graph:clusters\n' \
+ 'cluster_0 contains 5 nodes\n' \
+ 'cluster_1 contains 1 nodes\n' \
+ 'cluster_2 contains 3 nodes\n' \
+ 'cluster_3 contains 3 nodes\n'
def test_1783():
'''
# test ../lib/vmalloc
-import atexit
import os
import platform
-import shutil
import subprocess
import tempfile
assert os.path.exists(src)
# create a temporary directory to work in
- tmp = tempfile.mkdtemp()
- atexit.register(shutil.rmtree, tmp)
+ with tempfile.TemporaryDirectory() as tmp:
- # compile the unit tests
- dst = os.path.join(tmp, 'vmalloc-tests.exe')
- if platform.system() == 'Windows':
- subprocess.check_call(['cl', '-nologo', src, '-Fe:', dst])
- else:
- subprocess.check_call([os.environ.get('CC', 'cc'), '-Wall', '-Wextra',
- '-Werror', '-o', dst, src])
+ # compile the unit tests
+ dst = os.path.join(tmp, 'vmalloc-tests.exe')
+ if platform.system() == 'Windows':
+ subprocess.check_call(['cl', '-nologo', src, '-Fe:', dst])
+ else:
+ subprocess.check_call([os.environ.get('CC', 'cc'), '-Wall', '-Wextra',
+ '-Werror', '-o', dst, src])
- # run the unit tests
- subprocess.check_call([dst])
+ # run the unit tests
+ subprocess.check_call([dst])