[Buildroot] [RFC v2 2/3] support/testing/run-tests: run tests from temp directory
Colin Foster
colin.foster at in-advantage.com
Wed Jan 3 00:28:09 UTC 2024
When building with the BR2_EXTERNAL environment variable set, it becomes
desirable to have a place where tests from buildroot as well as
externals can live together.
In lieu of having two branches - one where tests are run internally and
one where they're copied to a temp directory - utilize a temp directory
for running all tests.
Signed-off-by: Colin Foster <colin.foster at in-advantage.com>
---
v2: New patch
---
support/testing/run-tests | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/support/testing/run-tests b/support/testing/run-tests
index 9d1174cb3b..dedb487ffd 100755
--- a/support/testing/run-tests
+++ b/support/testing/run-tests
@@ -3,6 +3,8 @@ import argparse
import multiprocessing
import os
import sys
+import tempfile
+import shutil
import nose2
@@ -40,7 +42,11 @@ def main():
args = parser.parse_args()
script_path = os.path.realpath(__file__)
- test_dir = os.path.dirname(script_path)
+ script_dir = os.path.dirname(script_path)
+
+ temp_dir = tempfile.TemporaryDirectory()
+ shutil.copytree(script_dir, temp_dir.name, dirs_exist_ok=True)
+ test_dir = temp_dir.name
try:
if args.stdout:
@@ -132,8 +138,7 @@ def main():
nose2.discover(argv=nose2_args)
finally:
- # Placeholder for try, to be undone shortly
- pass
+ shutil.rmtree(temp_dir.name)
if __name__ == "__main__":
sys.exit(main())
--
2.34.1
More information about the buildroot
mailing list