Sha256: e803a9586620aab3ad41c063a3ef9500897edc0a7a043fa7981c1545bb53a6cb

Contents?: true

Size: 1.88 KB

Versions: 23

Compression:

Stored size: 1.88 KB

Contents

#!/usr/bin/env python

# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Unit tests for the common.py file."""

import gyp.common
import unittest
import sys


class TestTopologicallySorted(unittest.TestCase):
  def test_Valid(self):
    """Test that sorting works on a valid graph with one possible order."""
    graph = {
        'a': ['b', 'c'],
        'b': [],
        'c': ['d'],
        'd': ['b'],
        }
    def GetEdge(node):
      return tuple(graph[node])
    self.assertEqual(
      gyp.common.TopologicallySorted(graph.keys(), GetEdge),
      ['a', 'c', 'd', 'b'])

  def test_Cycle(self):
    """Test that an exception is thrown on a cyclic graph."""
    graph = {
        'a': ['b'],
        'b': ['c'],
        'c': ['d'],
        'd': ['a'],
        }
    def GetEdge(node):
      return tuple(graph[node])
    self.assertRaises(
      gyp.common.CycleError, gyp.common.TopologicallySorted,
      graph.keys(), GetEdge)


class TestGetFlavor(unittest.TestCase):
  """Test that gyp.common.GetFlavor works as intended"""
  original_platform = ''

  def setUp(self):
    self.original_platform = sys.platform

  def tearDown(self):
    sys.platform = self.original_platform

  def assertFlavor(self, expected, argument, param):
    sys.platform = argument
    self.assertEqual(expected, gyp.common.GetFlavor(param))

  def test_platform_default(self):
    self.assertFlavor('freebsd', 'freebsd9' , {})
    self.assertFlavor('freebsd', 'freebsd10', {})
    self.assertFlavor('solaris', 'sunos5'   , {});
    self.assertFlavor('solaris', 'sunos'    , {});
    self.assertFlavor('linux'  , 'linux2'   , {});
    self.assertFlavor('linux'  , 'linux3'   , {});

  def test_param(self):
    self.assertFlavor('foobar', 'linux2' , {'flavor': 'foobar'})


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

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
libv8-3.16.14.19.1 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.19 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.18 vendor/gyp/pylib/gyp/common_test.py
arcabouco-0.2.13 vendor/bundle/gems/libv8-3.16.14.17/vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.17 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.16 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.15 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.14 vendor/gyp/pylib/gyp/common_test.py
libv8-tmpfork-3.16.14.13 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.13 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.12 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.11 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.10 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.8 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.8.rc1 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.7 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.6 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.5 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.4 vendor/gyp/pylib/gyp/common_test.py
libv8-3.16.14.3 vendor/gyp/pylib/gyp/common_test.py