From 6c9ae3b22f489224f3e17a68a9ee941567fd3d4c Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Tue, 11 Jun 2019 22:34:35 -0700 Subject: [PATCH] Fix Azure pipelines It was previously never reporting build errors. --- azure-pipelines.yml | 32 ++++++++++++++++---- wpiformat/test/test_includeguard.py | 45 +++++++++++++++-------------- wpiformat/wpiformat/cpplint.py | 2 +- 3 files changed, 51 insertions(+), 28 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 863af1c2..c3ace48b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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' @@ -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 "you@example.com" + 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 @@ -51,7 +61,7 @@ jobs: git --no-pager diff --exit-code HEAD displayName: 'Test' - - job: WindowsStyleguide + - job: Windows pool: vmImage: 'vs2017-win2016' @@ -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 "you@example.com" + 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 diff --git a/wpiformat/test/test_includeguard.py b/wpiformat/test/test_includeguard.py index 63158ac0..c8675d80 100644 --- a/wpiformat/test/test_includeguard.py +++ b/wpiformat/test/test_includeguard.py @@ -2,11 +2,14 @@ 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 + \ @@ -14,10 +17,10 @@ def test_includeguard(): 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 @@ -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 @@ -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) diff --git a/wpiformat/wpiformat/cpplint.py b/wpiformat/wpiformat/cpplint.py index 9f14fc88..c2cc48b9 100644 --- a/wpiformat/wpiformat/cpplint.py +++ b/wpiformat/wpiformat/cpplint.py @@ -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]