-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
59 lines (48 loc) · 1.82 KB
/
build.py
File metadata and controls
59 lines (48 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
import subprocess
import json
from avocado import Test
from avocado.utils import process
class BuildTest(Test):
def setUp(self):
"""
In the setup phase, get all parameters and construct the command
"""
self.env_dict = {}
# Iterate over all parameters and store them in env_dict
for path, key, value in self.params.iteritems():
self.env_dict[key] = value
self.log.info("env_dict: %s\n", self.env_dict)
def run_build_script(self):
"""
Execute the build.sh script with environment variables set from env_dict
"""
# Build the environment variable string
env_vars = ' '.join([f'{key}="{value}"' for key, value in self.env_dict.items()])
# Add environment variables to the build command
build_command = f"pwd;{env_vars} ./build.py.data/build.sh"
# Execute the command and capture the output
result = subprocess.run(
build_command,
shell=True, # Use shell to execute the command
capture_output=True, # Capture both stdout and stderr
text=True # Return output as a string
)
# Output the result of the command execution
if result.returncode == 0:
print("Build completed successfully:")
print(result.stdout) # Print standard output
else:
print("Build failed with error:")
print(result.stderr) # Print standard error
self.fail(result)
def test(self):
"""
Execute the build.sh script as part of the test case
"""
result = self.run_build_script() # Run the build.sh script
def tearDown(self):
"""
Tear down and log completion of the build test
"""
self.log.info("Build test finished.")