Skip to content

Commit

Permalink
Change shebang and call to cpplint.py to use python2, not "python"
Browse files Browse the repository at this point in the history
- Not compatible with Python 3, see #169. Follow PEP 394 and reserve "python"
  for scripts that are compatible with both Py2 and Py3.

- Remove artificial C++ style error in field.hpp

- This is the first change from upstream cpplint.py
google/styleguide@1b206ee

Calling "python -u" in cpplint_athena.sh has fixed the previously
jumbled stdout and stderr from cpplint.py calls to sys.stdout.write()
and sys.stderr.write() in the Jenkins log. However, unbuffered writes
may have been an issue with regression test crashes in macOS and on
Travis CI (see #47), but it was most likely a red herring due to the
known O_NONBLOCK bug in MPICH's mpirun(). Monitor this.

See if Jenkins log now contains pure output from git ls-tree command.
  • Loading branch information
felker committed Nov 2, 2018
1 parent 8131cf3 commit af3f7ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/field/field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FieldDiffusion;
class Field {
friend class Hydro;
public:
Field(MeshBlock *pmb, ParameterInput *pin); // test a really long comment that should cause the c++ linter to report a failure on all platforms
Field(MeshBlock *pmb, ParameterInput *pin);
~Field();

MeshBlock* pmy_block; // ptr to MeshBlock containing this Field
Expand Down
4 changes: 2 additions & 2 deletions tst/style/cpplint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python2
#
# Copyright (c) 2009 Google Inc. All rights reserved.
#
Expand Down Expand Up @@ -4301,7 +4301,7 @@ def GetLineWidth(line):
is_low_surrogate = 0xDC00 <= ord(uc) <= 0xDFFF
if not is_wide_build and is_low_surrogate:
width -= 1

width += 1
return width
else:
Expand Down
11 changes: 7 additions & 4 deletions tst/style/cpplint_athena.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@

# src/plimpton/ should probably be removed from the src/ folder. Exclude from style checks for now.

git ls-tree -r HEAD ../../src # is this command's output buffered in Jenkins?-- Appears normally in Travis CI, regardless of linting outcome

# Apply Google C++ Style Linter to all source code files at once:
git ls-tree -r HEAD ../../src # is this command's output buffered in Jenkins?
echo "Starting Google C++ Style cpplint.py test"
#set -e
find ../../src/ -type f \( -name "*.cpp" -o -name "*.hpp" \) -not -path "*/fft/plimpton/*" -not -name "defs.hpp" -print | xargs python -u ./cpplint.py --counting=detailed
#set +e
set -e
# Use "python2 -u" to prevent buffering of sys.stdout,stderr.write() calls in cpplint.py and mix-up in Jenkins logs,
# and since the local version of cpplint.py is currently incompatible with Python 3. Monitor potential errors on macOS from O_NONBLOCK.
find ../../src/ -type f \( -name "*.cpp" -o -name "*.hpp" \) -not -path "*/fft/plimpton/*" -not -name "defs.hpp" -print | xargs python2 -u ./cpplint.py --counting=detailed
set +e
echo "End of Google C++ Style cpplint.py test"

# Ignoring inline comments, check that all sqrt() and cbrt() function calls reside in std::, not global namespace
Expand Down

0 comments on commit af3f7ba

Please sign in to comment.