88
99from tools .cmake .common import CMakeTestCase , TESTABLE_CMAKE_FILES
1010
11+ from . import _list_cmake_cache
12+
1113
1214class TestPreset (CMakeTestCase ):
1315
@@ -201,12 +203,11 @@ def test_define_overridable_option_set_override_after_with_cache(self):
201203 # Setting the value after should not affect the cache.
202204 self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "default value" , "STRING" )
203205
204- def test_define_overridable_option_cli_override_with_set_override (self ):
206+ def test_define_overridable_option_override_existing_cache_with_cli (self ):
205207 _cmake_lists_txt = """
206208 cmake_minimum_required(VERSION 3.24)
207209 project(test_preset)
208210 include(${PROJECT_SOURCE_DIR}/preset.cmake)
209- set(EXECUTORCH_TEST_MESSAGE "set value")
210211 add_subdirectory(example)
211212 """
212213 _example_cmake_lists_txt = """
@@ -220,9 +221,14 @@ def test_define_overridable_option_cli_override_with_set_override(self):
220221 },
221222 }
222223 )
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+
223230 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" )
226232
227233 def test_set_overridable_option_before (self ):
228234 _cmake_lists_txt = """
0 commit comments