Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Unified Diff: tools/tests/licenses_test.py

Issue 2802723004: Fix an issue that tools/license.py fails when BUILD.gn is not directly (Closed)
Patch Set: Apply review comments. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/tests/OWNERS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/tests/licenses_test.py
diff --git a/tools/tests/licenses_test.py b/tools/tests/licenses_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..3a25f88b968f34251d9317190911f3ea5676ce56
--- /dev/null
+++ b/tools/tests/licenses_test.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+# Copyright (c) 2017 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.
+
+"""Unit tests for //tools/licenses.py.
+"""
+
+import os
+import sys
+import unittest
+
+REPOSITORY_ROOT = os.path.abspath(os.path.join(
+ os.path.dirname(__file__), '..', '..'))
+sys.path.append(os.path.join(REPOSITORY_ROOT, 'tools'))
+
+import licenses
+
+
+class LicensesTest(unittest.TestCase):
+
+ def test_get_third_party_deps_from_gn_deps_output(self):
+ third_party_deps = licenses.GetThirdPartyDepsFromGNDepsOutput(
+ '/home/example/src/net/BUILD.gn\n'
+ '/home/example/src/third_party/zlib/BUILD.gn\n'
+ '/home/example/src/third_party/cld_3/src/src/BUILD.gn\n')
+
+ # '/home/example/src/net' is not in the output because it's not a
+ # third_party dependency.
+ #
+ # It must return the direct sub-directory of "third_party". So it should
+ # return '/home/example/src/third_party/cld_3', not
+ # '/home/example/src/third_party/cld_3/src/src'.
+ assert third_party_deps == set([
+ '/home/example/src/third_party/zlib',
+ '/home/example/src/third_party/cld_3',
+ ])
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « tools/tests/OWNERS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698