189335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org#!/usr/bin/python 289335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 389335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org# Copyright 2014 Google Inc. 489335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org# 589335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org# Use of this source code is governed by a BSD-style license that can be 689335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org# found in the LICENSE file. 789335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 889335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org""" 989335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgTest gyp_to_android.py 1089335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org""" 1189335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 1289335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgimport os 1389335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgimport shutil 1489335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgimport sys 1589335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgimport tempfile 1689335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgimport test_variables 1789335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgimport unittest 1889335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 1989335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org# Path to gyp_to_android 2089335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgsys.path.append(test_variables.BIN_DIR) 2189335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 2289335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgimport gyp_to_android 2389335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 24d6656854697b2039fb88a4afd6bc1995bf6dfa02commit-bot@chromium.org 25d6656854697b2039fb88a4afd6bc1995bf6dfa02commit-bot@chromium.org 2689335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgclass AndroidMkCreationTest(unittest.TestCase): 2789335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 2889335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org def setUp(self): 2989335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org # Create a temporary directory for storing the output (Android.mk) 3089335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org self.__tmp_dir = tempfile.mkdtemp() 3189335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 3289335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org def test_create(self): 3389335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org gyp_to_android.main(self.__tmp_dir) 3489335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 3589335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org # Now there should be a file named 'Android.mk' inside __tmp_dir 36d6656854697b2039fb88a4afd6bc1995bf6dfa02commit-bot@chromium.org path_to_android_mk = os.path.join(self.__tmp_dir, 37d6656854697b2039fb88a4afd6bc1995bf6dfa02commit-bot@chromium.org test_variables.ANDROID_MK) 3889335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org self.assertTrue(os.path.exists(path_to_android_mk)) 3989335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 40d6656854697b2039fb88a4afd6bc1995bf6dfa02commit-bot@chromium.org # In addition, there should be an 'Android.mk' inside /tests/ 41d6656854697b2039fb88a4afd6bc1995bf6dfa02commit-bot@chromium.org path_to_tests_android_mk = os.path.join(self.__tmp_dir, 'tests', 42d6656854697b2039fb88a4afd6bc1995bf6dfa02commit-bot@chromium.org test_variables.ANDROID_MK) 43d6656854697b2039fb88a4afd6bc1995bf6dfa02commit-bot@chromium.org self.assertTrue(os.path.exists(path_to_tests_android_mk)) 4489335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 4589335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org def tearDown(self): 46d6656854697b2039fb88a4afd6bc1995bf6dfa02commit-bot@chromium.org # Remove self.__tmp_dir, which is no longer needed. 4789335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org shutil.rmtree(self.__tmp_dir) 4889335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 4989335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 5089335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgdef main(): 5189335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org loader = unittest.TestLoader() 5289335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org suite = loader.loadTestsFromTestCase(AndroidMkCreationTest) 5389335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org unittest.TextTestRunner(verbosity=2).run(suite) 5489335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org 5589335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.orgif __name__ == "__main__": 5689335631749b29ea92e55ed710f030692aa13297commit-bot@chromium.org main() 57