Skip to content

Commit def8a93

Browse files
yuslepukhinCopilot
andauthored
Fix minimal build (make it build with the recent changes) (#26222)
This pull request introduces a minor update to the test infrastructure and test files, focusing on improving build configuration and test utility usage. Build configuration: * Updated `cmake/onnxruntime_test_pch.cmake` to only enable precompiled headers for test targets when not performing a minimal build, preventing unnecessary PCH usage in minimal build scenarios. Test utility improvements: * Added an include for `asserts.h` in `onnxruntime/test/platform/file_io_test.cc`, ensuring test assertions are available and improving test reliability. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 11b23ad commit def8a93

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

cmake/onnxruntime_test_pch.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
55
target_precompile_headers(onnxruntime_test_all PRIVATE
66
"${CMAKE_CURRENT_SOURCE_DIR}/test_pch.h"
77
)
8-
target_precompile_headers(onnxruntime_provider_test PRIVATE
9-
"${CMAKE_CURRENT_SOURCE_DIR}/test_pch.h"
10-
)
8+
if (TARGET onnxruntime_provider_test)
9+
target_precompile_headers(onnxruntime_provider_test PRIVATE
10+
"${CMAKE_CURRENT_SOURCE_DIR}/test_pch.h"
11+
)
12+
endif()
1113
endif()
1214

1315
# Exclude certain files that might conflict with PCH

onnxruntime/core/providers/cpu/ml/tree_ensemble_attribute.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ struct TreeEnsembleAttributesV5 {
134134
for (auto i : nodes_modes_i) {
135135
nodes_modes.push_back(static_cast<NODE_MODE_ONNX>(i));
136136
}
137-
#else
138-
// GetVectorAttrsOrDefault is not part of the minimal build.
139-
// As a result, TreeEnsemble v5 cannot be available in this build.
140-
ORT_THROW("TreeEnsemble(ai.onnx.ml==5) is not supported with the minimal build.");
141-
#endif
142137

143138
aggregate_function = info.GetAttrOrDefault<int64_t>("aggregate_function", 1);
144139
leaf_targetids = info.GetAttrsOrDefault<int64_t>("leaf_targetids");
@@ -151,6 +146,11 @@ struct TreeEnsembleAttributesV5 {
151146
nodes_truenodeids = info.GetAttrsOrDefault<int64_t>("nodes_truenodeids");
152147
post_transform = info.GetAttrOrDefault<int64_t>("post_transform", 0);
153148
tree_roots = info.GetAttrsOrDefault<int64_t>("tree_roots");
149+
#else
150+
// GetVectorAttrsOrDefault is not part of the minimal build.
151+
// As a result, TreeEnsemble v5 cannot be available in this build.
152+
ORT_THROW("TreeEnsemble(ai.onnx.ml==5) is not supported with the minimal build.");
153+
#endif
154154
}
155155

156156
void convert_to_v3(TreeEnsembleAttributesV3<ThresholdType>& output) const {

onnxruntime/test/platform/device_discovery_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
#include "gtest/gtest.h"
77

8+
#if !defined(ORT_MINIMAL_BUILD) && !defined(_GAMING_XBOX)
89
namespace onnxruntime::test {
9-
1010
namespace {
1111

1212
std::vector<OrtHardwareDevice> GetDevicesByType(OrtHardwareDeviceType device_type) {
@@ -31,3 +31,4 @@ TEST(DeviceDiscoveryTest, HasCpuDevice) {
3131
}
3232

3333
} // namespace onnxruntime::test
34+
#endif // !defined(ORT_MINIMAL_BUILD) && !defined(_GAMING_XBOX)

onnxruntime/test/platform/file_io_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "gtest/gtest.h"
2020

2121
#include "core/common/span_utils.h"
22+
#include "test/util/include/asserts.h"
2223
#include "test/util/include/file_util.h"
2324

2425
namespace onnxruntime {

onnxruntime/test/providers/provider_test_utils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
#include "test/unittest_util/checkers.h"
77
#include "test/unittest_util/conversion.h"
8+
9+
#if !defined(ORT_MINIMAL_BUILD)
810
#include "test/unittest_util/model_tester.h"
911
#include "test/unittest_util/op_tester.h"
12+
#endif // !defined(ORT_MINIMAL_BUILD)
13+
1014
#include "test/unittest_util/run_options_config_keys.h"

0 commit comments

Comments
 (0)