Esempio n. 1
0
    def test_get_component_source_and_relative_path_oss_fuzz(self):
        """Test get comnponent source and relative path for OSS-Fuzz."""
        revisions_dict = {
            '/src/libass': {
                'url': 'https://github.com/libass/libass.git',
                'rev': '35dc4dd0e14e3afb4a2c7e319a3f4110e20c7cf2',
                'type': 'git'
            },
            '/src/fribidi': {
                'url': 'https://github.com/behdad/fribidi.git',
                'rev': '881b8d891cc61989ab8811b74d0e721f72bf913b',
                'type': 'git'
            }
        }

        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'/src/libass/test/test.c', revisions_dict),
            source_mapper.ComponentPath('/src/libass', 'test/test.c',
                                        'libass/test/test.c'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'/src/fribidi/lib/common.h', revisions_dict),
            source_mapper.ComponentPath('/src/fribidi', 'lib/common.h',
                                        'fribidi/lib/common.h'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'/src/not_existent', revisions_dict),
            source_mapper.ComponentPath())
Esempio n. 2
0
    def test_get_component_source_and_relative_path_chromium(self):
        """Test get component source and relative path for chromium."""
        revisions_dict = {
            '/src': {
                'url': 'https://chromium.googlesource.com/chromium/src.git',
                'rev': '1d783bc2a3629b94c963debfa3feaee27092dd92',
            },
            'src/v8': {
                'url': 'https://chromium.googlesource.com/v8/v8.git',
                'rev': '7fb2c3b6db3f889ea95851ca11dcb731b07a7925',
            }
        }

        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'content/common.h', revisions_dict),
            source_mapper.ComponentPath('/src', 'content/common.h',
                                        'content/common.h'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'content\common.h', revisions_dict),
            source_mapper.ComponentPath('/src', 'content/common.h',
                                        'content/common.h'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'c:\build\src\content\common.h', revisions_dict),
            source_mapper.ComponentPath('/src', 'content/common.h',
                                        'content/common.h'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'/mnt/build/src/content/common.h', revisions_dict),
            source_mapper.ComponentPath('/src', 'content/common.h',
                                        'content/common.h'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'../../third_party/WebKit/Source/platform/heap/Member.h',
                revisions_dict),
            source_mapper.ComponentPath(
                '/src', 'third_party/WebKit/Source/platform/heap/Member.h',
                'third_party/WebKit/Source/platform/heap/Member.h'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'v8/src/api.cc', revisions_dict),
            source_mapper.ComponentPath('src/v8', 'src/api.cc',
                                        'v8/src/api.cc'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'v8\src\api.cc', revisions_dict),
            source_mapper.ComponentPath('src/v8', 'src/api.cc',
                                        'v8/src/api.cc'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'c:\build\src\v8\src\api.cc', revisions_dict),
            source_mapper.ComponentPath('src/v8', 'src/api.cc',
                                        'v8/src/api.cc'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'/mnt/build/src/v8/src/api.cc', revisions_dict),
            source_mapper.ComponentPath('src/v8', 'src/api.cc',
                                        'v8/src/api.cc'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'/mnt/build/src/v8_overrides/init.cc', revisions_dict),
            source_mapper.ComponentPath('/src', 'v8_overrides/init.cc',
                                        'v8_overrides/init.cc'))
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'/mnt/build/non_existent', revisions_dict),
            source_mapper.ComponentPath())
        self.assertEqual(
            source_mapper.get_component_source_and_relative_path(
                r'c:\build\non_existent', revisions_dict),
            source_mapper.ComponentPath())