11cb0ef41Sopenharmony_ci#!/usr/bin/env python3
21cb0ef41Sopenharmony_ci# Copyright 2014 the V8 project authors. All rights reserved.
31cb0ef41Sopenharmony_ci# Redistribution and use in source and binary forms, with or without
41cb0ef41Sopenharmony_ci# modification, are permitted provided that the following conditions are
51cb0ef41Sopenharmony_ci# met:
61cb0ef41Sopenharmony_ci#
71cb0ef41Sopenharmony_ci#     * Redistributions of source code must retain the above copyright
81cb0ef41Sopenharmony_ci#       notice, this list of conditions and the following disclaimer.
91cb0ef41Sopenharmony_ci#     * Redistributions in binary form must reproduce the above
101cb0ef41Sopenharmony_ci#       copyright notice, this list of conditions and the following
111cb0ef41Sopenharmony_ci#       disclaimer in the documentation and/or other materials provided
121cb0ef41Sopenharmony_ci#       with the distribution.
131cb0ef41Sopenharmony_ci#     * Neither the name of Google Inc. nor the names of its
141cb0ef41Sopenharmony_ci#       contributors may be used to endorse or promote products derived
151cb0ef41Sopenharmony_ci#       from this software without specific prior written permission.
161cb0ef41Sopenharmony_ci#
171cb0ef41Sopenharmony_ci# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
181cb0ef41Sopenharmony_ci# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
191cb0ef41Sopenharmony_ci# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
201cb0ef41Sopenharmony_ci# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
211cb0ef41Sopenharmony_ci# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
221cb0ef41Sopenharmony_ci# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
231cb0ef41Sopenharmony_ci# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
241cb0ef41Sopenharmony_ci# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
251cb0ef41Sopenharmony_ci# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
261cb0ef41Sopenharmony_ci# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
271cb0ef41Sopenharmony_ci# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci# Wraps test execution with a coverage analysis. To get the best speed, the
301cb0ef41Sopenharmony_ci# native python coverage version >= 3.7.1 should be installed.
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ciimport coverage
331cb0ef41Sopenharmony_ciimport os
341cb0ef41Sopenharmony_ciimport unittest
351cb0ef41Sopenharmony_ciimport sys
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_cidef Main(argv):
391cb0ef41Sopenharmony_ci  script_path = os.path.dirname(os.path.abspath(__file__))
401cb0ef41Sopenharmony_ci  cov = coverage.coverage(include=([os.path.join(script_path, '*.py')]))
411cb0ef41Sopenharmony_ci  cov.start()
421cb0ef41Sopenharmony_ci  import test_scripts
431cb0ef41Sopenharmony_ci  alltests = map(unittest.TestLoader().loadTestsFromTestCase, [
441cb0ef41Sopenharmony_ci    test_scripts.ToplevelTest,
451cb0ef41Sopenharmony_ci    test_scripts.ScriptTest,
461cb0ef41Sopenharmony_ci  ])
471cb0ef41Sopenharmony_ci  unittest.TextTestRunner(verbosity=2).run(unittest.TestSuite(alltests))
481cb0ef41Sopenharmony_ci  cov.stop()
491cb0ef41Sopenharmony_ci  print(cov.report())
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ciif __name__ == '__main__':
531cb0ef41Sopenharmony_ci  sys.exit(Main(sys.argv))
54