aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-04-05 22:51:49 +0200
committerAnna Henningsen <anna@addaleax.net>2018-04-05 23:00:02 +0200
commite37effe4cec98688e75d770f4d0b7f68927e2b73 (patch)
treee7efa0fc8a2139f9aba4b66ea3f3613262f20cef /deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
parent026f6b787a7a23597790f1f0b076c58a68c7c38b (diff)
downloadandroid-node-v8-e37effe4cec98688e75d770f4d0b7f68927e2b73.tar.gz
android-node-v8-e37effe4cec98688e75d770f4d0b7f68927e2b73.tar.bz2
android-node-v8-e37effe4cec98688e75d770f4d0b7f68927e2b73.zip
Revert "deps: upgrade npm to 5.8.0"
This reverts commit 25a816dcda7b1db0929501acfe13f2fe5119759b. PR-URL: https://github.com/nodejs/node/pull/19837 Reviewed-By: Gus Caplan <me@gus.host>
Diffstat (limited to 'deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common_test.py')
-rwxr-xr-xdeps/npm/node_modules/node-gyp/gyp/pylib/gyp/common_test.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common_test.py b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
new file mode 100755
index 0000000000..ad6f9a1438
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common_test.py
@@ -0,0 +1,72 @@
+#!/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()