Skip to content

Commit

Permalink
Give exec its own dict for globals and locals
Browse files Browse the repository at this point in the history
  • Loading branch information
Zehvogel committed Aug 29, 2023
1 parent 948460e commit 21e1813
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion k4FWCore/scripts/k4run
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 5 additions & 0 deletions test/k4FWCoreTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
20 changes: 20 additions & 0 deletions test/k4FWCoreTest/options/TestExec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (c) 2014-2023 Key4hep-Project.
#
# This file is part of Key4hep.
# See https://key4hep.github.io/key4hep-doc/ for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
a = 5
comp = [a for i in range(3)]

0 comments on commit 21e1813

Please sign in to comment.