def test_gn_args(self):
        """Tests the args.gn parsing of extra values."""
        self.builder = binary_providers.PdfiumBuilder(
            self.testcase, self.definition,
            libs.make_options(goma_dir='/goma/dir'))

        os.makedirs(self.testcase_dir)
        with open(os.path.join(self.testcase_dir, 'args.gn'), 'w') as f:
            f.write('Not correct args.gn')
        build_dir = os.path.join(common.CLUSTERFUZZ_BUILDS_DIR, '1234_build')
        os.makedirs(build_dir)
        with open(os.path.join(build_dir, 'args.gn'), 'w') as f:
            f.write('goma_dir = /not/correct/dir')

        self.builder.build_directory = self.testcase_dir
        self.builder.setup_gn_args()

        self.assert_exact_calls(self.mock.execute, [
            mock.call('gn', 'gen  %s' % self.testcase_dir,
                      '/chrome/source/dir')
        ])
        with open(os.path.join(self.testcase_dir, 'args.gn'), 'r') as f:
            self.assertEqual(f.read(), ('goma_dir = "/goma/dir"\n'
                                        'pdf_is_standalone = true\n'
                                        'use_goma = true'))
 def setUp(self):
     helpers.patch(self, [
         'clusterfuzz.binary_providers.sha_from_revision',
         'clusterfuzz.binary_providers.get_third_party_sha'
     ])
     self.builder = binary_providers.PdfiumBuilder(
         libs.make_testcase(revision=1234), libs.make_definition(),
         libs.make_options())
 def setUp(self):
   helpers.patch(self, [
       'clusterfuzz.binary_providers.PdfiumBuilder.setup_gn_args',
       'clusterfuzz.common.execute',
       'clusterfuzz.binary_providers.PdfiumBuilder.get_goma_cores',
       'clusterfuzz.binary_providers.sha_from_revision',
       'clusterfuzz.binary_providers.get_pdfium_sha'])
   self.mock.get_goma_cores.return_value = 120
   self.mock.sha_from_revision.return_value = 'chrome_sha'
   testcase = mock.Mock(id=1234, build_url='', revision=54321)
   self.mock_os_environment({'V8_SRC': '/chrome/source/dir'})
   binary_definition = mock.Mock(source_var='V8_SRC')
   self.builder = binary_providers.PdfiumBuilder(
       testcase, binary_definition, False, '/goma/dir', None, False)
 def setUp(self):
   self.setup_fake_filesystem()
   helpers.patch(self, ['clusterfuzz.common.execute',
                        'clusterfuzz.binary_providers.sha_from_revision',
                        'clusterfuzz.binary_providers.get_pdfium_sha'])
   self.sha = '1a2s3d4f5g'
   self.mock.sha_from_revision.return_value = 'chrome_sha'
   self.mock.get_pdfium_sha = self.sha
   testcase = mock.Mock(id=1234, build_url='', revision=54321,
                        gn_args='use_goma = true')
   self.mock_os_environment({'V8_SRC': '/chrome/source/dir'})
   binary_definition = mock.Mock(source_var='V8_SRC')
   self.builder = binary_providers.PdfiumBuilder(
       testcase, binary_definition, False, '/goma/dir', None, False)
   self.testcase_dir = os.path.expanduser(os.path.join('~', 'test_dir'))
   self.mock.execute.return_value = (0, '12345')