Skip to content

Commit

Permalink
Fix Azure pipelines
Browse files Browse the repository at this point in the history
It was previously never reporting build errors.
  • Loading branch information
calcmogul committed Jun 18, 2019
1 parent f9a8d78 commit 6c9ae3b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 28 deletions.
32 changes: 26 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resources:
options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro"

jobs:
- job: Styleguide
- job: Linux
pool:
vmImage: 'Ubuntu 16.04'

Expand All @@ -32,17 +32,27 @@ jobs:
sudo python3 setup.py install --optimize=1 --skip-build
displayName: 'Build'
- script: |
# Make sure .git/refs/heads/master exists
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git checkout -b pr
git checkout master
git checkout pr
cd wpiformat
python3 setup.py test
cd ..
python3 -m wpiformat -v
cd wpiformat
# One file
python3 -m wpiformat -f wpiformat\__init__.py -v
python3 -m wpiformat -f wpiformat/__init__.py -v
# Absolute path to file
python3 -m wpiformat -f C:\projects\styleguide\wpiformat\wpiformat\__init__.py -v
python3 -m wpiformat -f /__w/1/s/wpiformat/wpiformat/__init__.py -v
# Multiple files
python3 -m wpiformat -f wpiformat\__init__.py wpiformat\__main__.py -v
python3 -m wpiformat -f wpiformat/__init__.py wpiformat/__main__.py -v
# Directory
python3 -m wpiformat -f wpiformat -v
Expand All @@ -51,7 +61,7 @@ jobs:
git --no-pager diff --exit-code HEAD
displayName: 'Test'
- job: WindowsStyleguide
- job: Windows
pool:
vmImage: 'vs2017-win2016'

Expand All @@ -66,14 +76,24 @@ jobs:
py -3 setup.py install --optimize=1 --skip-build
displayName: 'Build'
- powershell: |
# Make sure .git/refs/heads/master exists
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git checkout -b pr
git checkout master
git checkout pr
cd wpiformat
py -3 setup.py test
cd ..
py -3 -m wpiformat -v
cd wpiformat
# One file
py -3 -m wpiformat -f wpiformat\__init__.py -v
# Absolute path to file
py -3 -m wpiformat -f C:\projects\styleguide\wpiformat\wpiformat\__init__.py -v
py -3 -m wpiformat -f D:\a\1\s\wpiformat\wpiformat\__init__.py -v
# Multiple files
py -3 -m wpiformat -f wpiformat\__init__.py wpiformat\__main__.py -v
Expand Down
45 changes: 24 additions & 21 deletions wpiformat/test/test_includeguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@

from test.tasktest import *
from wpiformat.includeguard import IncludeGuard
from wpiformat.task import Task


def test_includeguard():
test = TaskTest(IncludeGuard())

repo_root = os.path.basename(Task.get_repo_root()).upper()

# Fix incorrect include guard
test.add_input("./Test.h",
"#ifndef WRONG_H" + os.linesep + \
"#define WRONG_C" + os.linesep + \
os.linesep + \
"#endif" + os.linesep)
test.add_output(
"#ifndef STYLEGUIDE_TEST_H_" + os.linesep + \
"#define STYLEGUIDE_TEST_H_" + os.linesep + \
"#ifndef " + repo_root + "_TEST_H_" + os.linesep + \
"#define " + repo_root + "_TEST_H_" + os.linesep + \
os.linesep + \
"#endif // STYLEGUIDE_TEST_H_" + os.linesep, True, True)
"#endif // " + repo_root + "_TEST_H_" + os.linesep, True, True)

# Ensure nested preprocessor statements are handled properly for incorrect
# include guard
Expand All @@ -30,20 +33,20 @@ def test_includeguard():
"#endif" + os.linesep + \
"#endif" + os.linesep)
test.add_output(
"#ifndef STYLEGUIDE_TEST_H_" + os.linesep + \
"#define STYLEGUIDE_TEST_H_" + os.linesep + \
"#ifndef " + repo_root + "_TEST_H_" + os.linesep + \
"#define " + repo_root + "_TEST_H_" + os.linesep + \
os.linesep + \
"#if SOMETHING" + os.linesep + \
"// do something" + os.linesep + \
"#endif" + os.linesep + \
"#endif // STYLEGUIDE_TEST_H_" + os.linesep, True, True)
"#endif // " + repo_root + "_TEST_H_" + os.linesep, True, True)

# Don't touch correct include guard
test.add_input("./Test.h",
"#ifndef STYLEGUIDE_TEST_H_" + os.linesep + \
"#define STYLEGUIDE_TEST_H_" + os.linesep + \
"#ifndef " + repo_root + "_TEST_H_" + os.linesep + \
"#define " + repo_root + "_TEST_H_" + os.linesep + \
os.linesep + \
"#endif // STYLEGUIDE_TEST_H_" + os.linesep)
"#endif // " + repo_root + "_TEST_H_" + os.linesep)
test.add_latest_input_as_output(True)

# Fail on missing include guard
Expand All @@ -56,27 +59,27 @@ def test_includeguard():

# Ensure include guard roots are processed correctly
test.add_input("./Test.h",
"#ifndef STYLEGUIDE_WPIFORMAT_TEST_H_" + os.linesep + \
"#define STYLEGUIDE_WPIFORMAT_TEST_H_" + os.linesep + \
"#ifndef " + repo_root + "_WPIFORMAT_TEST_H_" + os.linesep + \
"#define " + repo_root + "_WPIFORMAT_TEST_H_" + os.linesep + \
os.linesep + \
"#endif // STYLEGUIDE_WPIFORMAT_TEST_H_" + os.linesep)
"#endif // " + repo_root + "_WPIFORMAT_TEST_H_" + os.linesep)
test.add_output(
"#ifndef STYLEGUIDE_TEST_H_" + os.linesep + \
"#define STYLEGUIDE_TEST_H_" + os.linesep + \
"#ifndef " + repo_root + "_TEST_H_" + os.linesep + \
"#define " + repo_root + "_TEST_H_" + os.linesep + \
os.linesep + \
"#endif // STYLEGUIDE_TEST_H_" + os.linesep, True, True)
"#endif // " + repo_root + "_TEST_H_" + os.linesep, True, True)

# Ensure leading underscores are removed (this occurs if the user doesn't
# include a trailing "/" in the include guard root)
test.add_input("./Test/Test.h",
"#ifndef STYLEGUIDE_WPIFORMAT_TEST_TEST_H_" + os.linesep + \
"#define STYLEGUIDE_WPIFORMAT_TEST_TEST_H_" + os.linesep + \
"#ifndef " + repo_root + "_WPIFORMAT_TEST_TEST_H_" + os.linesep + \
"#define " + repo_root + "_WPIFORMAT_TEST_TEST_H_" + os.linesep + \
os.linesep + \
"#endif // STYLEGUIDE_WPIFORMAT_TEST_TEST_H_" + os.linesep)
"#endif // " + repo_root + "_WPIFORMAT_TEST_TEST_H_" + os.linesep)
test.add_output(
"#ifndef STYLEGUIDE_TEST_H_" + os.linesep + \
"#define STYLEGUIDE_TEST_H_" + os.linesep + \
"#ifndef " + repo_root + "_TEST_H_" + os.linesep + \
"#define " + repo_root + "_TEST_H_" + os.linesep + \
os.linesep + \
"#endif // STYLEGUIDE_TEST_H_" + os.linesep, True, True)
"#endif // " + repo_root + "_TEST_H_" + os.linesep, True, True)

test.run(OutputType.FILE)
2 changes: 1 addition & 1 deletion wpiformat/wpiformat/cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def IsSourceFile(filename):
return _source_regex.search(filename)


_USAGE = """
_USAGE = r"""
Syntax: cpplint.py [--repository=path]
[--headers=header_regex]
[--srcs=src_regex]
Expand Down

0 comments on commit 6c9ae3b

Please sign in to comment.