summaryrefslogtreecommitdiffstats
path: root/tools/code_coverage
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 17:25:34 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 17:25:34 +0000
commitcb155a802bdc49cfafea1c41e0f0a92168f1da09 (patch)
treebf0fae4855c7f4458d8e959455b9d12d6cd54d9d /tools/code_coverage
parent9bec23957253b83955c4096903ad6293d1c6e1bb (diff)
downloadchromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.zip
chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.gz
chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.bz2
Fix python scripts in src/tools/
Make sure that: - shebang is only present for executable files - shebang is #!/usr/bin/env python - __main__ is only present for executable files - file's executable bit is coherent Also fix EOF LF to be only one. TBR=timurrrr@chromium.org BUG=105108 TEST= Review URL: http://codereview.chromium.org/8678023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/code_coverage')
-rwxr-xr-x[-rw-r--r--]tools/code_coverage/coverage.py6
-rwxr-xr-xtools/code_coverage/croc.py30
-rw-r--r--tools/code_coverage/croc_html.py34
-rw-r--r--tools/code_coverage/croc_scan.py33
-rwxr-xr-x[-rw-r--r--]tools/code_coverage/croc_scan_test.py40
-rwxr-xr-x[-rw-r--r--]tools/code_coverage/croc_test.py43
-rwxr-xr-x[-rw-r--r--]tools/code_coverage/process_coverage.py13
7 files changed, 23 insertions, 176 deletions
diff --git a/tools/code_coverage/coverage.py b/tools/code_coverage/coverage.py
index a34a230..6e524ea 100644..100755
--- a/tools/code_coverage/coverage.py
+++ b/tools/code_coverage/coverage.py
@@ -1,5 +1,5 @@
#!/bin/env python
-# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -107,7 +107,6 @@ class Coverage(object):
self._dir = tempfile.mkdtemp()
self._archive = archive
-
def SetUp(self, binaries):
"""Set up the platform specific environment and instrument the binaries for
coverage.
@@ -157,7 +156,6 @@ class Coverage(object):
self.instrumented = True
return True
-
def TearDown(self):
"""Tear down method.
@@ -188,7 +186,6 @@ class Coverage(object):
# Reset the instrumented flag.
self.instrumented = False
-
def RunTest(self, src_root, test):
"""Run tests and collect the .coverage file
@@ -238,7 +235,6 @@ class Coverage(object):
# Return the intermediate .coverage file
return coverage_file
-
def Upload(self, list_coverage, upload_path, sym_path=None, src_root=None):
"""Upload the results to the dashboard.
diff --git a/tools/code_coverage/croc.py b/tools/code_coverage/croc.py
index 6999bf5..770e7f5 100755
--- a/tools/code_coverage/croc.py
+++ b/tools/code_coverage/croc.py
@@ -1,33 +1,7 @@
#!/usr/bin/env python
-# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Crocodile - compute coverage numbers for Chrome coverage dashboard."""
@@ -741,7 +715,5 @@ def Main(argv):
return 0
-#------------------------------------------------------------------------------
-
if __name__ == '__main__':
sys.exit(Main(sys.argv))
diff --git a/tools/code_coverage/croc_html.py b/tools/code_coverage/croc_html.py
index 79ec85d..0e07a5a 100644
--- a/tools/code_coverage/croc_html.py
+++ b/tools/code_coverage/croc_html.py
@@ -1,33 +1,6 @@
-#!/usr/bin/python2.4
-#
-# Copyright 2009, Google Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
"""Crocodile HTML output."""
@@ -450,4 +423,3 @@ class CrocHtml(object):
# Write files in root directory
self.WriteRoot()
-
diff --git a/tools/code_coverage/croc_scan.py b/tools/code_coverage/croc_scan.py
index e40b45e..8d0e2e8 100644
--- a/tools/code_coverage/croc_scan.py
+++ b/tools/code_coverage/croc_scan.py
@@ -1,33 +1,6 @@
-#!/usr/bin/python2.4
-#
-# Copyright 2009, Google Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
"""Crocodile source scanners."""
diff --git a/tools/code_coverage/croc_scan_test.py b/tools/code_coverage/croc_scan_test.py
index 17fc7fa..a69b28a 100644..100755
--- a/tools/code_coverage/croc_scan_test.py
+++ b/tools/code_coverage/croc_scan_test.py
@@ -1,45 +1,14 @@
-#!/usr/bin/python2.4
-#
-# Copyright 2009, Google Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#!/usr/bin/env python
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
"""Unit tests for croc_scan.py."""
-#import os
import re
-#import sys
-#import StringIO
import unittest
import croc_scan
-#------------------------------------------------------------------------------
-
class TestScanner(unittest.TestCase):
"""Tests for croc_scan.Scanner."""
@@ -213,7 +182,6 @@ class TestScanFile(unittest.TestCase):
self.assertEqual(croc_scan.ScanFile('bar4', 'ObjC++'), 'scan cpp bar4')
self.assertEqual(croc_scan.ScanFile('bar', 'fortran'), [])
-#------------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()
diff --git a/tools/code_coverage/croc_test.py b/tools/code_coverage/croc_test.py
index 36fc546..7c2521c 100644..100755
--- a/tools/code_coverage/croc_test.py
+++ b/tools/code_coverage/croc_test.py
@@ -1,33 +1,7 @@
-#!/usr/bin/python2.4
-#
-# Copyright 2009, Google Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#!/usr/bin/env python
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
"""Unit tests for Crocodile."""
@@ -36,8 +10,6 @@ import StringIO
import unittest
import croc
-#------------------------------------------------------------------------------
-
class TestCoverageStats(unittest.TestCase):
"""Tests for croc.CoverageStats."""
@@ -62,8 +34,6 @@ class TestCoverageStats(unittest.TestCase):
c.Add({'a': 4, 'd': 3})
self.assertEqual(c, {'a': 5, 'b': 0, 'c': 5, 'd': 3})
-#------------------------------------------------------------------------------
-
class TestCoveredFile(unittest.TestCase):
"""Tests for croc.CoveredFile."""
@@ -144,8 +114,6 @@ class TestCoveredFile(unittest.TestCase):
'files_covered': 1,
})
-#------------------------------------------------------------------------------
-
class TestCoveredDir(unittest.TestCase):
"""Tests for croc.CoveredDir."""
@@ -193,8 +161,6 @@ class TestCoveredDir(unittest.TestCase):
d2.subdirs = {'/a/b/d': d4, '/a/b/e': d5}
self.assertEqual(d1.GetTree(), 'a/\n b/\n d/\n e/\n c/')
-#------------------------------------------------------------------------------
-
class TestCoverage(unittest.TestCase):
"""Tests for croc.Coverage."""
@@ -787,7 +753,6 @@ GetStat('nosuch') = 42
# ParseLcovFile()
# PrintTree()
-#------------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()
diff --git a/tools/code_coverage/process_coverage.py b/tools/code_coverage/process_coverage.py
index 8f6ccbf..07d83ac 100644..100755
--- a/tools/code_coverage/process_coverage.py
+++ b/tools/code_coverage/process_coverage.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -345,9 +345,9 @@ def SendPost(req):
def main():
- if sys.platform[:5] != 'linux': # Run this only on Linux
+ if not sys.platform.startswith('linux'):
print 'This script is supported only on Linux'
- os.exit(1)
+ return 0
# Command line parsing
parser = optparse.OptionParser()
@@ -395,18 +395,19 @@ def main():
if percent == None:
# TODO(niranjan): Add logging.
print 'Failed to generate code coverage'
- os.exit(1)
+ return 1
else:
# TODO(niranjan): Do something with the code coverage numbers
pass
else:
print 'Unsupported platform'
- os.exit(1)
+ return 1
# Prep coverage results for dashboard and post new set.
parsed_data = ParseCoverageDataForDashboard(options.lcov_path)
PostResultsToDashboard(options.lcov_path, parsed_data, options.post_url)
+ return 0
if __name__ == '__main__':
- main()
+ sys.exit(main())