Skip to content

Get licence header test working again. #3272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,20 @@ install:
fi

script:
- if [[ $TEST_TARGET == 'default' ]]; then
python -m iris.tests.runner --default-tests --system-tests --coding-tests --print-failed-images --num-processors=3;
# Capture install-dir: As a test command must be last for get Travis to check
# the RC, so it's best to start each operation with an absolute cd.
- INSTALL_DIR=$(pwd)

- >
if [[ $TEST_TARGET == 'default' ]]; then
export IRIS_REPO_DIR=$INSTALL_DIR;
python -m iris.tests.runner --default-tests --system-tests --print-failed-images --num-processors=3;
fi

- if [[ $TEST_TARGET == 'example' ]]; then
python -m iris.tests.runner --example-tests --print-failed-images --num-processors=3;
fi

# Capture install-dir: As a test command must be last for get Travis to check
# the RC, so it's best to start each operation with an absolute cd.
- INSTALL_DIR=$(pwd)

- >
if [[ $TEST_TARGET == 'doctest' ]]; then
MPL_RC_DIR=$HOME/.config/matplotlib;
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/analysis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2018, Met Office
# (C) British Crown Copyright 2010 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/analysis/_interpolation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2014 - 2017, Met Office
# (C) British Crown Copyright 2014 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/analysis/calculus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2017, Met Office
# (C) British Crown Copyright 2010 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/analysis/cartography.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2018, Met Office
# (C) British Crown Copyright 2010 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/experimental/stratify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2017, Met Office
# (C) British Crown Copyright 2017 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/fileformats/name_loaders.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2013 - 2017, Met Office
# (C) British Crown Copyright 2013 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/fileformats/pp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2018, Met Office
# (C) British Crown Copyright 2010 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/integration/plot/test_vector_plots.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2014 - 2016, Met Office
# (C) British Crown Copyright 2014 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
27 changes: 16 additions & 11 deletions lib/iris/tests/test_coding_standards.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2013 - 2018, Met Office
# (C) British Crown Copyright 2013 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -63,14 +63,16 @@
# Guess iris repo directory of Iris - realpath is used to mitigate against
# Python finding the iris package via a symlink.
IRIS_DIR = os.path.realpath(os.path.dirname(iris.__file__))
REPO_DIR = os.path.dirname(os.path.dirname(IRIS_DIR))
DOCS_DIR = os.path.join(REPO_DIR, 'docs', 'iris')
IRIS_INSTALL_DIR = os.path.dirname(os.path.dirname(IRIS_DIR))
DOCS_DIR = os.path.join(IRIS_INSTALL_DIR, 'docs', 'iris')
DOCS_DIR = iris.config.get_option('Resources', 'doc_dir', default=DOCS_DIR)
exclusion = ['Makefile', 'build']
DOCS_DIRS = glob(os.path.join(DOCS_DIR, '*'))
DOCS_DIRS = [DOC_DIR for DOC_DIR in DOCS_DIRS if os.path.basename(DOC_DIR) not
in exclusion]

# Get a dirpath to the git repository : allow setting with an environment
# variable, so Travis can test for headers in the repo, not the installation.
IRIS_REPO_DIRPATH = os.environ.get('IRIS_REPO_DIR', IRIS_INSTALL_DIR)

# pycodestyle / pep8 error codes that should be ignored:
PYCODESTYLE_IGNORE_OPTIONS = (
Expand Down Expand Up @@ -279,14 +281,16 @@ def last_change_by_fname():

"""
# Check the ".git" folder exists at the repo dir.
if not os.path.isdir(os.path.join(REPO_DIR, '.git')):
raise ValueError('{} is not a git repository.'.format(REPO_DIR))
if not os.path.isdir(os.path.join(IRIS_REPO_DIRPATH, '.git')):
msg = '{} is not a git repository.'
raise ValueError(msg.format(IRIS_REPO_DIRPATH))

# Call "git whatchanged" to get the details of all the files and when
# they were last changed.
output = subprocess.check_output(['git', 'whatchanged',
"--pretty=TIME:%ct"],
cwd=REPO_DIR)
cwd=IRIS_REPO_DIRPATH)

output = output.decode().split('\n')
res = {}
for fname, dt in TestLicenseHeaders.whatchanged_parse(output):
Expand All @@ -311,14 +315,15 @@ def test_license_headers(self):

try:
last_change_by_fname = self.last_change_by_fname()
except ValueError:
except ValueError as err:
# Caught the case where this is not a git repo.
return self.skipTest('Iris installation did not look like a '
'git repo.')
msg = ('Iris installation did not look like a git repo?'
'\nERR = {}\n\n')
return self.skipTest(msg.format(str(err)))

failed = False
for fname, last_change in sorted(last_change_by_fname.items()):
full_fname = os.path.join(REPO_DIR, fname)
full_fname = os.path.join(IRIS_REPO_DIRPATH, fname)
if full_fname.endswith('.py') and os.path.isfile(full_fname) and \
not any(fnmatch(fname, pat) for pat in exclude_patterns):
with open(full_fname) as fh:
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/test_merge.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2017, Met Office
# (C) British Crown Copyright 2010 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2017, Met Office
# (C) British Crown Copyright 2010 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2014 - 2017, Met Office
# (C) British Crown Copyright 2014 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/unit/analysis/test_Aggregator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2013 - 2015, Met Office
# (C) British Crown Copyright 2013 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/unit/analysis/test_PROPORTION.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2013 - 2017, Met Office
# (C) British Crown Copyright 2013 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/unit/analysis/test_RMS.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2013 - 2015, Met Office
# (C) British Crown Copyright 2013 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down
2 changes: 1 addition & 1 deletion requirements/gen_conda_requirements.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2017, Met Office
# (C) British Crown Copyright 2017 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down