webrtc/tools_webrtc/libs/generate_licenses_test.py
Christoffer Dewerin 81a9117fb7 Roll chromium_revision 5350dd2460..d5c79b109a (1281218:1283550)
Change log: 5350dd2460..d5c79b109a
Full diff: 5350dd2460..d5c79b109a

Changed dependencies
* fuchsia_version: version:19.20240320.0.1..version:20.20240404.3.1
* src/base: 218e807167..dbb0eee8e8
* src/build: 04c884cbad..6d974542a0
* src/buildtools/linux64: git_revision:93ee9b91423c1f1f53fb5f6cba7b8eef6247a564..git_revision:415b3b19e094cd4b6982147693485df65037f942
* src/buildtools/mac: git_revision:93ee9b91423c1f1f53fb5f6cba7b8eef6247a564..git_revision:415b3b19e094cd4b6982147693485df65037f942
* src/buildtools/win: git_revision:93ee9b91423c1f1f53fb5f6cba7b8eef6247a564..git_revision:415b3b19e094cd4b6982147693485df65037f942
* src/ios: 77324ec269..0bf6089d48
* src/testing: 977e41b6f7..02d496a8fc
* src/third_party: d0b81aaaa6..2831ffa216
* src/third_party/android_build_tools/manifest_merger: HxnrwdWmIAhi90brIHiGZ4zmnmgKxP4PD0ZsJX6j-mUC..wtRWPCJVk_NA2GQp0fI-1i-JaPzYJwp6w3udjEhgni4C
* src/third_party/android_deps/libs/com_squareup_okio_okio_jvm: version:2@3.3.0.cr1..version:2@3.7.0.cr1
* src/third_party/android_deps/libs/com_squareup_wire_wire_runtime_jvm: version:2@4.7.0.cr1..version:2@4.9.7.cr1
* src/third_party/androidx: piz2tht912VQfctH5Z23YCOpLUBoypzE5ymRqB3vgLkC..1qBFaGY_bIR5f12dL7zKpePRlN4UxIDze8xDv_a0sQEC
* src/third_party/boringssl/src: https://boringssl.googlesource.com/boringssl.git/+log/368d0d87d0..f94f3ed396
* src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/bb95c35019..0b9e7b8830
* src/third_party/depot_tools: e545830db2..246580c7b8
* src/third_party/ffmpeg: 52d8ef3799..bdcb0b447f
* src/third_party/googletest/src: 77afe8e014..f10e11fb27
* src/third_party/kotlinc/current: -kUQ1HWm0wwi5pXKSqIplyfSInHmtRS9cVUzg-2l-Y0C..Rr02Gf2EkaeSs3EhSUHhPqDHSd1AzimrM6cRYUJCPjQC
* src/third_party/libc++abi/src: 1317096ef8..932d253fed
* src/third_party/libvpx/source/libvpx: d790001fd5..6445da1b40
* src/third_party/perfetto: 6fd518058c..7609c6712c
* src/third_party/r8: eHemH-tzLR3jqxqGYiQu6AYGLAPyFYG7klrqbvu1mcQC..kPZJoj3X2XUBofNCeOoUj0P8XChVFgtiNQqMnTwhcOwC
* src/tools: 09b9b5615b..7dad49cbe0
* src/tools/luci-go: git_revision:a84377ac0800e2330d02c3dcbf7b4b74a06d6a5b..git_revision:06dc7a1f2eeb1d095f7876799458328a44438df1
* src/tools/luci-go: git_revision:a84377ac0800e2330d02c3dcbf7b4b74a06d6a5b..git_revision:06dc7a1f2eeb1d095f7876799458328a44438df1
Added dependencies
* src/third_party/android_deps/libs/com_squareup_moshi_moshi_adapters
* src/third_party/android_deps/libs/com_squareup_moshi_moshi
DEPS diff: 5350dd2460..d5c79b109a/DEPS

Clang version changed llvmorg-19-init-6501-g5b544b51:llvmorg-19-init-7229-g315c88c5
Details: 5350dd2460..d5c79b109a/tools/clang/scripts/update.py

BUG=None

Change-Id: I95eaf05240916eeeaa04f806e7e1523a31abab56
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/345960
Commit-Queue: Christoffer Dewerin <jansson@webrtc.org>
Reviewed-by: Jeremy Leconte <jleconte@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42010}
2024-04-08 08:12:19 +00:00

126 lines
4.4 KiB
Python
Executable file

#!/usr/bin/env vpython3
# pylint: disable=protected-access,unused-argument
# Copyright 2017 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
import unittest
from mock import patch
from generate_licenses import LicenseBuilder
class TestLicenseBuilder(unittest.TestCase):
@staticmethod
def _fake_run_gn(buildfile_dir, target):
return """
{
"target1": {
"deps": [
"//a/b/third_party/libname1:c",
"//a/b/third_party/libname2:c(//d/e/f:g)",
"//a/b/third_party/libname3/c:d(//e/f/g:h)",
"//a/b/not_third_party/c"
]
}
}
"""
def test_parse_library_name(self):
self.assertEqual(
LicenseBuilder._parse_library_name('//a/b/third_party/libname1:c'),
'libname1')
self.assertEqual(
LicenseBuilder._parse_library_name(
'//a/b/third_party/libname2:c(d)'), 'libname2')
self.assertEqual(
LicenseBuilder._parse_library_name(
'//a/b/third_party/libname3/c:d(e)'), 'libname3')
self.assertEqual(
LicenseBuilder._parse_library_name('//a/b/not_third_party/c'),
None)
def test_parse_library_simple_match(self):
builder = LicenseBuilder([], [], {}, {})
self.assertEqual(builder._parse_library('//a/b/third_party/libname:c'),
'libname')
def test_parse_library_regex_no_match_fallbacks_to_default_libname(self):
lib_dict = {
'libname:foo.*': ['path/to/LICENSE'],
}
builder = LicenseBuilder([], [], lib_dict, {})
self.assertEqual(
builder._parse_library('//a/b/third_party/libname:bar_java'),
'libname')
def test_parse_library_regex_match(self):
lib_regex_dict = {
'libname:foo.*': ['path/to/LICENSE'],
}
builder = LicenseBuilder([], [], {}, lib_regex_dict)
self.assertEqual(
builder._parse_library('//a/b/third_party/libname:foo_bar_java'),
'libname:foo.*')
def test_parse_library_regex_match_with_sub_directory(self):
lib_regex_dict = {
'libname/foo:bar.*': ['path/to/LICENSE'],
}
builder = LicenseBuilder([], [], {}, lib_regex_dict)
self.assertEqual(
builder._parse_library('//a/b/third_party/libname/foo:bar_java'),
'libname/foo:bar.*')
def test_parse_library_regex_match_with_star_inside(self):
lib_regex_dict = {
'libname/foo.*bar.*': ['path/to/LICENSE'],
}
builder = LicenseBuilder([], [], {}, lib_regex_dict)
self.assertEqual(
builder._parse_library(
'//a/b/third_party/libname/fooHAHA:bar_java'),
'libname/foo.*bar.*')
@patch('generate_licenses.LicenseBuilder._run_gn', _fake_run_gn)
def test_get_third_party_libraries_without_regex(self):
builder = LicenseBuilder([], [], {}, {})
self.assertEqual(
builder._get_third_party_libraries('out/arm', 'target1'),
set(['libname1', 'libname2', 'libname3']))
@patch('generate_licenses.LicenseBuilder._run_gn', _fake_run_gn)
def test_get_third_party_libraries_with_regex(self):
lib_regex_dict = {
'libname2:c.*': ['path/to/LICENSE'],
}
builder = LicenseBuilder([], [], {}, lib_regex_dict)
self.assertEqual(
builder._get_third_party_libraries('out/arm', 'target1'),
set(['libname1', 'libname2:c.*', 'libname3']))
@patch('generate_licenses.LicenseBuilder._run_gn', _fake_run_gn)
def test_generate_license_text_fail_if_unknown_library(self):
lib_dict = {
'simple_library': ['path/to/LICENSE'],
}
builder = LicenseBuilder(['dummy_dir'], ['dummy_target'], lib_dict, {})
with self.assertRaises(Exception) as context:
builder.generate_license_text('dummy/dir')
self.assertEqual(
context.exception.args[0],
'Missing licenses for third_party targets: '
'libname1, libname2, libname3')
if __name__ == '__main__':
unittest.main()