21
21
import argparse
22
22
23
23
# Function to load environment variables from a YAML file
24
+
25
+
24
26
def load_env_from_yaml (file_path ):
25
27
"""
26
28
Load environment variables from the specified YAML file.
27
-
29
+
28
30
The YAML file contains key-value pairs that define --app environment variables
29
31
required for the test scripts to run. These variables configurations needed during the test execution.
30
-
32
+
31
33
This function reads the YAML file and sets the environment variables
32
34
in the current process's environment using os.environ.
33
-
35
+
34
36
Args:
35
37
file_path (str): The path to the YAML file containing the environment variables.
36
38
"""
@@ -40,6 +42,7 @@ def load_env_from_yaml(file_path):
40
42
key , value = line .strip ().split (': ' , 1 )
41
43
os .environ [key ] = value
42
44
45
+
43
46
def main (search_directory , env_file ):
44
47
# Determine the root directory of the CHIP project
45
48
chip_root = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' , '..' ))
@@ -102,10 +105,12 @@ def main(search_directory, env_file):
102
105
print (f"Running command: { full_command } " )
103
106
subprocess .run (full_command , shell = True , check = True )
104
107
108
+
105
109
if __name__ == "__main__" :
106
110
parser = argparse .ArgumentParser (description = "Run Python test scripts." )
107
- parser .add_argument ("--search-directory" , type = str , default = "src/python_testing" , help = "Directory to search for Python scripts." )
111
+ parser .add_argument ("--search-directory" , type = str , default = "src/python_testing" ,
112
+ help = "Directory to search for Python scripts." )
108
113
parser .add_argument ("--env-file" , type = str , default = "/tmp/test_env.yaml" , help = "Path to the environment variables file." )
109
-
114
+
110
115
args = parser .parse_args ()
111
116
main (args .search_directory , args .env_file )
0 commit comments