| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 #!/usr/bin/env python | 
|  | 2 # pylint: disable=relative-import,protected-access,unused-argument | 
|  | 3 | 
|  | 4 #  Copyright 2017 The WebRTC project authors. All Rights Reserved. | 
|  | 5 # | 
|  | 6 #  Use of this source code is governed by a BSD-style license | 
|  | 7 #  that can be found in the LICENSE file in the root of the source | 
|  | 8 #  tree. An additional intellectual property rights grant can be found | 
|  | 9 #  in the file PATENTS.  All contributing project authors may | 
|  | 10 #  be found in the AUTHORS file in the root of the source tree. | 
|  | 11 | 
|  | 12 import os | 
|  | 13 import sys | 
|  | 14 | 
|  | 15 SRC = os.path.abspath(os.path.join( | 
|  | 16                       os.path.dirname((__file__)), os.pardir, os.pardir)) | 
|  | 17 sys.path.append(os.path.join(SRC, 'third_party', 'pymock')) | 
|  | 18 | 
|  | 19 import mock | 
|  | 20 import unittest | 
|  | 21 | 
|  | 22 from generate_licenses import LicenseBuilder | 
|  | 23 | 
|  | 24 | 
|  | 25 class TestLicenseBuilder(unittest.TestCase): | 
|  | 26   @staticmethod | 
|  | 27   def _FakeRunGN(buildfile_dir, target): | 
|  | 28     return """ | 
|  | 29     { | 
|  | 30       "target1": { | 
|  | 31         "deps": [ | 
|  | 32           "//a/b/third_party/libname1:c", | 
|  | 33           "//a/b/third_party/libname2:c(//d/e/f:g)", | 
|  | 34           "//a/b/third_party/libname3/c:d(//e/f/g:h)", | 
|  | 35           "//a/b/not_third_party/c" | 
|  | 36         ] | 
|  | 37       } | 
|  | 38     } | 
|  | 39     """ | 
|  | 40 | 
|  | 41   def testParseLibrary(self): | 
|  | 42     self.assertEquals(LicenseBuilder._ParseLibrary( | 
|  | 43             '//a/b/third_party/libname1:c').group(1), | 
|  | 44         'libname1') | 
|  | 45     self.assertEquals(LicenseBuilder._ParseLibrary( | 
|  | 46             '//a/b/third_party/libname2:c(d)').group(1), | 
|  | 47         'libname2') | 
|  | 48     self.assertEquals(LicenseBuilder._ParseLibrary( | 
|  | 49             '//a/b/third_party/libname3/c:d(e)').group(1), | 
|  | 50         'libname3') | 
|  | 51     self.assertEquals(LicenseBuilder._ParseLibrary('//a/b/not_third_party/c'), | 
|  | 52         None) | 
|  | 53 | 
|  | 54   @mock.patch('generate_licenses.LicenseBuilder._RunGN', _FakeRunGN) | 
|  | 55   def testGetThirdPartyLibraries(self): | 
|  | 56     self.assertEquals(LicenseBuilder._GetThirdPartyLibraries( | 
|  | 57             'out/arm', 'target1'), | 
|  | 58         set(['libname1', 'libname2', 'libname3'])) | 
|  | 59 | 
|  | 60 | 
|  | 61 if __name__ == '__main__': | 
|  | 62   unittest.main() | 
| OLD | NEW | 
|---|