summaryrefslogtreecommitdiff
path: root/deps/v8/build/android/gyp/util/build_utils_test.py
blob: d462f0c6769a992f50633e08381deb7b73782407 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import collections
import os
import sys
import unittest

sys.path.insert(
    0, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)))
from util import build_utils

_DEPS = collections.OrderedDict()
_DEPS['a'] = []
_DEPS['b'] = []
_DEPS['c'] = ['a']
_DEPS['d'] = ['a']
_DEPS['e'] = ['f']
_DEPS['f'] = ['a', 'd']
_DEPS['g'] = []
_DEPS['h'] = ['d', 'b', 'f']
_DEPS['i'] = ['f']


class BuildUtilsTest(unittest.TestCase):
  def testGetSortedTransitiveDependencies_all(self):
    TOP = _DEPS.keys()
    EXPECTED = ['a', 'b', 'c', 'd', 'f', 'e', 'g', 'h', 'i']
    actual = build_utils.GetSortedTransitiveDependencies(TOP, _DEPS.get)
    self.assertEqual(EXPECTED, actual)

  def testGetSortedTransitiveDependencies_leaves(self):
    TOP = ['c', 'e', 'g', 'h', 'i']
    EXPECTED = ['a', 'c', 'd', 'f', 'e', 'g', 'b', 'h', 'i']
    actual = build_utils.GetSortedTransitiveDependencies(TOP, _DEPS.get)
    self.assertEqual(EXPECTED, actual)

  def testGetSortedTransitiveDependencies_leavesReverse(self):
    TOP = ['i', 'h', 'g', 'e', 'c']
    EXPECTED = ['a', 'd', 'f', 'i', 'b', 'h', 'g', 'e', 'c']
    actual = build_utils.GetSortedTransitiveDependencies(TOP, _DEPS.get)
    self.assertEqual(EXPECTED, actual)


if __name__ == '__main__':
  unittest.main()