Sha256: fa1075513acd28a7bf8caca2a318836b04a4dba7bc197044be585a607a502a53

Contents?: true

Size: 1.92 KB

Versions: 51

Compression:

Stored size: 1.92 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('openbsd', 'openbsd5' , {})
    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

51 entries across 44 versions & 19 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
disco_app-0.18.0 test/dummy/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
disco_app-0.18.2 test/dummy/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
tang-0.2.1 spec/tang_app/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
ruby2js-4.0.4 lib/tasks/testrails/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
ruby2js-4.0.3 lib/tasks/testrails/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
tang-0.2.0 spec/tang_app/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
tang-0.1.0 spec/tang_app/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
tang-0.0.9 spec/tang_app/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
enju_library-0.3.8 spec/dummy/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
ilog-0.4.1 node_modules/node-gyp/gyp/pylib/gyp/common_test.py
ilog-0.4.0 node_modules/node-gyp/gyp/pylib/gyp/common_test.py
ilog-0.3.3 node_modules/node-gyp/gyp/pylib/gyp/common_test.py
jester-data-8.0.0 node_modules/node-gyp/gyp/pylib/gyp/common_test.py
ezii-os-5.2.1 node_modules/node-gyp/gyp/pylib/gyp/common_test.py
ezii-os-2.0.1 node_modules/node-gyp/gyp/pylib/gyp/common_test.py
ezii-os-1.1.0 node_modules/node-gyp/gyp/pylib/gyp/common_test.py
ezii-os-1.0.0 node_modules/node-gyp/gyp/pylib/gyp/common_test.py