MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / build_cmake_tests

Function build_cmake_tests

cpp/run_automated_tests.py:38–93  ·  view source on GitHub ↗
(cmake_files, executable_pattern)

Source from the content-addressed store, hash-verified

36
37
38def build_cmake_tests(cmake_files, executable_pattern):
39 global build_sub_dir
40 run_files = []
41
42 if len(cmake_files) == 0:
43 return [1, []]
44
45 has_error = False
46 base_dir = os.getcwd()
47 build_dir = os.path.join(base_dir, build_sub_dir)
48
49 os.makedirs(name=build_dir, exist_ok=True)
50
51 cmake_args = os.getenv("EXTRA_CMAKE_ARGS")
52
53 parallel_build = os.getenv("PARALLEL_BUILD")
54
55 for cmake_file in cmake_files:
56 source_dir = os.path.dirname(cmake_file)
57 module_build_dir = os.path.join(build_dir, source_dir)
58 os.makedirs(name=module_build_dir, exist_ok=True)
59 os.chdir(module_build_dir)
60
61 cmake_command = ["cmake"]
62 if cmake_args is not None:
63 cmake_command.append(cmake_args)
64 cmake_command.append(os.path.join(base_dir, source_dir))
65
66 if sys.platform == "win32":
67 cmake_command.append("-DBIN_SUB_DIR=/Debug")
68
69 result_code = subprocess.call(cmake_command, shell=False)
70 if result_code != 0:
71 print(f"Error with cmake for {source_dir}")
72 has_error = True
73 continue
74
75 if parallel_build is not None:
76 print("building parallel")
77 result_code = subprocess.call(
78 ["cmake", "--build", ".", "--parallel", f"{parallel_build}"],
79 shell=False,
80 )
81 else:
82 result_code = subprocess.call(["cmake", "--build", "."], shell=False)
83
84 if result_code != 0:
85 has_error = True
86 continue
87 for executable in executable_pattern:
88 run_files.extend(glob.glob(f"{module_build_dir}{executable}"))
89
90 if has_error:
91 return [1, []]
92 else:
93 return [0, run_files]
94
95

Callers 3

build_testsFunction · 0.85
test_hello_serviceFunction · 0.85
run_special_case_testsFunction · 0.85

Calls 2

joinMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected