• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2013 The Flutter Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4import unittest
5
6import os
7import imp
8SKY_TOOLS = os.path.dirname(os.path.abspath(__file__))
9gn = imp.load_source('gn', os.path.join(SKY_TOOLS, 'gn'))
10
11
12class GNTestCase(unittest.TestCase):
13    def _expect_build_dir(self, arg_list, expected_build_dir):
14        args = gn.parse_args(['gn'] + arg_list)
15        self.assertEquals(gn.get_out_dir(args), expected_build_dir)
16
17    def test_get_out_dir(self):
18        self._expect_build_dir(['--debug'], 'out/Debug')
19        self._expect_build_dir(['--release'], 'out/Release')
20        self._expect_build_dir(['--ios'], 'out/ios_Debug')
21        self._expect_build_dir(['--ios', '--release'], 'out/ios_Release')
22        self._expect_build_dir(['--android'], 'out/android_Debug')
23        self._expect_build_dir(['--android', '--release'], 'out/android_Release')
24
25    def _gn_args(self, arg_list):
26        args = gn.parse_args(['gn'] + arg_list)
27        return gn.to_gn_args(args)
28
29    def test_to_gn_args(self):
30        # This would not necessarily be true on a 32-bit machine?
31        self.assertEquals(self._gn_args(['--ios', '--simulator'])['target_cpu'], 'x64')
32        self.assertEquals(self._gn_args(['--ios'])['target_cpu'], 'arm')
33
34
35if __name__ == '__main__':
36    unittest.main()
37