From ac4d8e307e270dd4177a33b29b70fa3958fd44ab Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Tue, 29 Aug 2023 09:08:31 +0200 Subject: [PATCH] Give exec with its own dict for globals and locals --- k4FWCore/scripts/k4run | 2 +- test/k4FWCoreTest/CMakeLists.txt | 5 +++++ test/k4FWCoreTest/options/TestExec.py | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/k4FWCoreTest/options/TestExec.py diff --git a/k4FWCore/scripts/k4run b/k4FWCore/scripts/k4run index 9427ef86..6c480288 100755 --- a/k4FWCore/scripts/k4run +++ b/k4FWCore/scripts/k4run @@ -23,7 +23,7 @@ seen_files = set() option_db = {} def load_file(file): - exec(file.read()) + exec(file.read(), {}) def add_arguments(parser, app_mgr): diff --git a/test/k4FWCoreTest/CMakeLists.txt b/test/k4FWCoreTest/CMakeLists.txt index 707acc07..fafa3201 100644 --- a/test/k4FWCoreTest/CMakeLists.txt +++ b/test/k4FWCoreTest/CMakeLists.txt @@ -177,3 +177,8 @@ add_test(NAME Testk4runHelpOnly set_test_env(Testk4runHelpOnly) set_tests_properties(Testk4runHelpOnly PROPERTIES PASS_REGULAR_EXPRESSION "show this help message and exit") + +add_test(NAME TestExec + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + COMMAND ${K4RUN} --dry-run options/TestExec.py) +set_test_env(TestExec) \ No newline at end of file diff --git a/test/k4FWCoreTest/options/TestExec.py b/test/k4FWCoreTest/options/TestExec.py new file mode 100644 index 00000000..448bb3bb --- /dev/null +++ b/test/k4FWCoreTest/options/TestExec.py @@ -0,0 +1,2 @@ +a = 5 +comp = [a for i in range(3)] \ No newline at end of file