@@ -108,3 +108,44 @@ def test_build_arch(
108
108
mock_sh_command .mock_calls ,
109
109
)
110
110
mock_make .assert_called ()
111
+
112
+
113
+ class BaseTestForCmakeRecipe (BaseTestForMakeRecipe ):
114
+ """
115
+ An unittest for testing any recipe using `cmake`. It inherits from
116
+ `BaseTestForMakeRecipe` but we override the build method to match the cmake
117
+ build method.
118
+
119
+ .. note:: Note that Some cmake recipe may need some more specific testing
120
+ ...but this should cover the basics.
121
+ """
122
+
123
+ @mock .patch ("pythonforandroid.util.chdir" )
124
+ @mock .patch ("pythonforandroid.build.ensure_dir" )
125
+ @mock .patch ("pythonforandroid.archs.glob" )
126
+ @mock .patch ("pythonforandroid.archs.find_executable" )
127
+ def test_build_arch (
128
+ self ,
129
+ mock_find_executable ,
130
+ mock_glob ,
131
+ mock_ensure_dir ,
132
+ mock_current_directory ,
133
+ ):
134
+ mock_find_executable .return_value = self .expected_compiler .format (
135
+ android_ndk = self .ctx ._ndk_dir
136
+ )
137
+ mock_glob .return_value = ["llvm" ]
138
+ with mock .patch (
139
+ f"pythonforandroid.recipes.{ self .recipe_name } .sh.make"
140
+ ) as mock_make , mock .patch (
141
+ f"pythonforandroid.recipes.{ self .recipe_name } .sh.cmake"
142
+ ) as mock_cmake :
143
+ self .recipe .build_arch (self .arch )
144
+
145
+ # make sure that the mocked methods are actually called
146
+ mock_glob .assert_called ()
147
+ mock_ensure_dir .assert_called ()
148
+ mock_current_directory .assert_called ()
149
+ mock_find_executable .assert_called ()
150
+ mock_cmake .assert_called ()
151
+ mock_make .assert_called ()
0 commit comments