Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
gn_test.py
Go to the documentation of this file.
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.
4
5import imp
6import os
7import unittest
8
9SKY_TOOLS = os.path.dirname(os.path.abspath(__file__))
10gn = imp.load_source('gn', os.path.join(SKY_TOOLS, 'gn'))
11
12
13class GNTestCase(unittest.TestCase):
14
15 def _expect_build_dir(self, arg_list, expected_build_dir):
16 args = gn.parse_args(['gn'] + arg_list)
17 self.assertEqual(gn.get_out_dir(args), expected_build_dir)
18
20 self._expect_build_dir(['--runtime-mode', 'debug'], os.path.join('out', 'host_debug'))
21 self._expect_build_dir(['--runtime-mode', 'release'], os.path.join('out', 'host_release'))
22 self._expect_build_dir(['--ios'], os.path.join('out', 'ios_debug'))
23 self._expect_build_dir(['--ios', '--darwin-extension-safe'],
24 os.path.join('out', 'ios_debug_extension_safe'))
25 self._expect_build_dir(['--ios', '--runtime-mode', 'release'],
26 os.path.join('out', 'ios_release'))
27 self._expect_build_dir(['--ios', '--darwin-extension-safe', '--runtime-mode', 'release'],
28 os.path.join('out', 'ios_release_extension_safe'))
29 self._expect_build_dir(['--android'], os.path.join('out', 'android_debug'))
30 self._expect_build_dir(['--android', '--runtime-mode', 'release'],
31 os.path.join('out', 'android_release'))
32
33 def _gn_args(self, arg_list):
34 args = gn.parse_args(['gn'] + arg_list)
35 return gn.to_gn_args(args)
36
37 def test_to_gn_args(self):
38 # This would not necessarily be true on a 32-bit machine?
39 self.assertEqual(
40 self._gn_args(['--ios', '--simulator', '--simulator-cpu', 'x64'])['target_cpu'], 'x64'
41 )
42 self.assertEqual(self._gn_args(['--ios'])['target_cpu'], 'arm64')
43
45 with self.assertRaises(Exception):
46 self._gn_args(['--android', '--enable-unittests'])
47
49 with self.assertRaises(Exception):
50 self._gn_args(['--ios', '--enable-unittests'])
51
52 def test_parse_size(self):
53 self.assertEqual(gn.parse_size('5B'), 5)
54 self.assertEqual(gn.parse_size('5KB'), 5 * 2**10)
55 self.assertEqual(gn.parse_size('5MB'), 5 * 2**20)
56 self.assertEqual(gn.parse_size('5GB'), 5 * 2**30)
57
58
59if __name__ == '__main__':
60 unittest.main()
test_get_out_dir(self)
Definition gn_test.py:19
_expect_build_dir(self, arg_list, expected_build_dir)
Definition gn_test.py:15
_gn_args(self, arg_list)
Definition gn_test.py:33
test_cannot_use_android_and_enable_unittests(self)
Definition gn_test.py:44
test_to_gn_args(self)
Definition gn_test.py:37
test_parse_size(self)
Definition gn_test.py:52
test_cannot_use_ios_and_enable_unittests(self)
Definition gn_test.py:48
parse_args(args)
Definition gn.py:575