8
8
9
9
from tools .cmake .common import CMakeTestCase , TESTABLE_CMAKE_FILES
10
10
11
+ from . import _list_cmake_cache
12
+
11
13
12
14
class TestPreset (CMakeTestCase ):
13
15
@@ -201,12 +203,11 @@ def test_define_overridable_option_set_override_after_with_cache(self):
201
203
# Setting the value after should not affect the cache.
202
204
self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "default value" , "STRING" )
203
205
204
- def test_define_overridable_option_cli_override_with_set_override (self ):
206
+ def test_define_overridable_option_override_existing_cache_with_cli (self ):
205
207
_cmake_lists_txt = """
206
208
cmake_minimum_required(VERSION 3.24)
207
209
project(test_preset)
208
210
include(${PROJECT_SOURCE_DIR}/preset.cmake)
209
- set(EXECUTORCH_TEST_MESSAGE "set value")
210
211
add_subdirectory(example)
211
212
"""
212
213
_example_cmake_lists_txt = """
@@ -220,9 +221,14 @@ def test_define_overridable_option_cli_override_with_set_override(self):
220
221
},
221
222
}
222
223
)
224
+ self .run_cmake ()
225
+ self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "default value" , "STRING" )
226
+
227
+ # Since we cache the get operations, clear it so that it's read again for tests.
228
+ _list_cmake_cache .cache_clear ()
229
+
223
230
self .run_cmake (cmake_args = ["-DEXECUTORCH_TEST_MESSAGE='cli value'" ])
224
- # If an option is set through cmake, it should NOT be overridable from the CLI.
225
- self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "set value" , "STRING" )
231
+ self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "cli value" , "STRING" )
226
232
227
233
def test_set_overridable_option_before (self ):
228
234
_cmake_lists_txt = """
0 commit comments