#!/usr/bin/env python
# coding=utf-8

# Copyright 2018 Earth Sciences Department, BSC-CNS
#
# This file is part of HERMESv3_GR.
#
# HERMESv3_GR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# HERMESv3_GR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with HERMESv3_GR. If not, see <http://www.gnu.org/licenses/>.
"""Script to run the tests for EarthDiagnostics and generate the code coverage report"""

import os
import sys
import pytest


work_path = os.path.abspath(os.path.join(os.path.dirname(__file__)))
os.chdir(work_path)
print(work_path)


version = sys.version_info[0]
report_dir = 'tests/report/python{}'.format(version)
errno = pytest.main([
    'tests',
    '--ignore=tests/report',
    '--cov=hermesv3_gr',
    '--cov-report=term',
    '--cov-report=html:{}/coverage_html'.format(report_dir),
    '--cov-report=xml:{}/coverage.xml'.format(report_dir),
])
sys.exit(errno)
