From 8f4d66db04aa7fb82211c8c78efb659ec4b2f406 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Fri, 4 Jan 2019 18:55:31 -0800 Subject: [PATCH] tests/build_samples: Use temporary directories to avoid in-source builds --- tests/build_samples.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/build_samples.py b/tests/build_samples.py index 222a7df354..4622fd87bc 100644 --- a/tests/build_samples.py +++ b/tests/build_samples.py @@ -1,6 +1,7 @@ import os import subprocess import sys +import tempfile SAMPLES_TO_BUILD = [ 'asteroids', @@ -8,13 +9,24 @@ SAMPLES_TO_BUILD = [ SAMPLES_DIR = os.path.join(os.path.dirname(__file__), '..', 'samples') def main(): + build_base = tempfile.TemporaryDirectory() + dist_dir = tempfile.TemporaryDirectory() + for sample in SAMPLES_TO_BUILD: sampledir = os.path.join(SAMPLES_DIR, sample) os.chdir(sampledir) + args = [ + sys.executable, + 'setup.py', + 'bdist_apps', + '--build-base', build_base.name, + '--dist-dir', dist_dir.name, + ] + # This will raise a CalledProcessError if the build fails, which will cause # this script to fail - subprocess.check_call([sys.executable, 'setup.py', 'bdist_apps']) + subprocess.check_call(args) if __name__ == '__main__': main()