Exemple #1
0
 def UploadCL(self, short_description=False):
     cli_helpers.Step('UPLOAD CL: %s' % self.story)
     if short_description:
         commit_message = 'Automated upload'
     else:
         commit_message = (
             'Add %s system health story\n\nThis CL was created automatically '
             'with tools/perf/update_wpr script' % self.story)
     if self.bug_id:
         commit_message += '\n\nBug: %s' % self.bug_id
     if subprocess.call(['git', 'diff', '--quiet']):
         cli_helpers.Run(['git', 'commit', '-a', '-m', commit_message])
     commit_msg_file = os.path.join(self.output_dir, 'commit_message.tmp')
     with open(commit_msg_file, 'w') as fd:
         fd.write(commit_message)
     return cli_helpers.Run(
         [
             'git',
             'cl',
             'upload',
             '--reviewers',
             ','.join(self.reviewers),
             '--force',  # to prevent message editor from appearing
             '--message-file',
             commit_msg_file
         ],
         ok_fail=True)
 def testRun(self, check_call_mock, print_mock):
   check_call_mock.side_effect = [subprocess.CalledProcessError(87, ['cmd'])]
   with self.assertRaises(subprocess.CalledProcessError):
     cli_helpers.Run(['cmd', 'arg with space'], env={'a': 'b'})
   check_call_mock.assert_called_once_with(
       ['cmd', 'arg with space'], env={'a': 'b'})
   print_mock.assert_called_once_with('\033[94mcmd \'arg with space\'\033[0m')
Exemple #3
0
def _GitAddArtifactHash(archive):
    """Stages changes into SHA1 file for commit."""
    archive_sha1 = archive + '.sha1'
    if not os.path.exists(archive_sha1):
        cli_helpers.Error('Could not find upload artifact: {sha}',
                          sha=archive_sha1)
        return False
    cli_helpers.Run(['git', 'add', archive_sha1])
    return True
Exemple #4
0
def _PrintResultsHTMLInfo(out_file):
    results_file = out_file + '.results.html'
    histogram_json = out_file + '.hist.json'
    histogram_csv = out_file + '.hist.csv'

    cli_helpers.Run([RESULTS2JSON, results_file, histogram_json],
                    env=_PrepareEnv())
    cli_helpers.Run([HISTOGRAM2CSV, histogram_json, histogram_csv],
                    env=_PrepareEnv())

    cli_helpers.Info('Metrics results: file://{path}', path=results_file)
    names = set([
        'console:error:network', 'console:error:js', 'console:error:all',
        'console:error:security'
    ])
    with open(histogram_csv) as f:
        for line in f.readlines():
            line = line.split(',')
            if line[0] in names:
                cli_helpers.Info('    %-26s%s' % ('[%s]:' % line[0], line[2]))
Exemple #5
0
def _UploadArchiveToGoogleStorage(archive):
    """Uploads specified WPR archive to the GS."""
    cli_helpers.Run([
        'upload_to_google_storage.py', '--bucket=chrome-partner-telemetry',
        archive
    ])
Exemple #6
0
 def _CreateBranch(self):
     new_branch_name = '%s-%d' % (self._SanitizedBranchPrefix(),
                                  random.randint(0, 10000))
     cli_helpers.Run(['git', 'new-branch', new_branch_name])
 def testRunWithNonListCommand(self):
     with self.assertRaises(ValueError):
         cli_helpers.Run('cmd with args')
 def testRunOkFail(self, check_call_mock, print_mock):
     del print_mock  # Unused.
     check_call_mock.side_effect = [
         subprocess.CalledProcessError(87, ['cmd'])
     ]
     cli_helpers.Run(['cmd'], ok_fail=True)