-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor temporary test directory creation
Now the includeorder, includeguard, and config tests use a temporary directory with their own .styleguide files instead of using the wpiformat .styleguide file. This allowed massively simplifying wpiformat's .styleguide file.
- Loading branch information
Showing
8 changed files
with
287 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,7 @@ | ||
cppHeaderFileInclude { | ||
\.h$ | ||
\.hpp$ | ||
\.inc$ | ||
} | ||
|
||
cppSrcFileInclude { | ||
\.cpp$ | ||
} | ||
|
||
# Extra "/" used by unit tests | ||
generatedFileExclude { | ||
/cpplint\.py$ | ||
cpplint\.py$ | ||
} | ||
|
||
modifiableFileExclude { | ||
\.png$ | ||
} | ||
|
||
licenseUpdateExclude { | ||
Excluded\.h$ | ||
} | ||
|
||
# Ordered this way to ensure tests find longest match | ||
includeGuardRoots { | ||
wpiformat/ | ||
wpiformat/Test/ | ||
} | ||
|
||
# Used by unit tests | ||
includeProject { | ||
^ctre/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
/*{padding}Company Name{padding}*/ | ||
/* Copyright (c) {year} Company Name. All Rights Reserved.{padding}*/ | ||
// Copyright (c) {year} FIRST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,45 @@ | ||
import os | ||
|
||
from .tempdir import * | ||
from wpiformat.config import Config | ||
|
||
|
||
def test_config(): | ||
config_file = Config(os.path.abspath(os.getcwd()), ".styleguide") | ||
assert config_file.is_modifiable_file( | ||
"." + os.sep + "wpiformat" + os.sep + "javaguidelink.png" | ||
) | ||
assert config_file.is_generated_file( | ||
"." + os.sep + "wpiformat" + os.sep + "wpiformat" + os.sep + "cpplint.py" | ||
) | ||
with OpenTemporaryDirectory(): | ||
with open(".styleguide", "w") as file: | ||
file.write( | ||
r"""cppHeaderFileInclude { | ||
\.h$ | ||
\.inc$ | ||
} | ||
cppSrcFileInclude { | ||
\.cpp$ | ||
} | ||
# Extra "/" used by unit tests | ||
generatedFileExclude { | ||
/cpplint\.py$ | ||
} | ||
modifiableFileExclude { | ||
\.png$ | ||
} | ||
""" | ||
) | ||
|
||
config_file = Config(os.path.abspath(os.getcwd()), ".styleguide") | ||
assert config_file.is_modifiable_file( | ||
"." + os.sep + "wpiformat" + os.sep + "javaguidelink.png" | ||
) | ||
assert config_file.is_generated_file( | ||
"." + os.sep + "wpiformat" + os.sep + "wpiformat" + os.sep + "cpplint.py" | ||
) | ||
|
||
assert not config_file.is_generated_file( | ||
"." + os.sep + "wpiformat" + os.sep + "diff_cpplint.py" | ||
) | ||
assert not config_file.is_generated_file( | ||
"." + os.sep + "wpiformat" + os.sep + "update_cpplint.py" | ||
) | ||
assert not config_file.is_modifiable_file( | ||
"." + os.sep + "wpiformat" + os.sep + "license.txt" | ||
) | ||
assert not config_file.is_generated_file( | ||
"." + os.sep + "wpiformat" + os.sep + "diff_cpplint.py" | ||
) | ||
assert not config_file.is_generated_file( | ||
"." + os.sep + "wpiformat" + os.sep + "update_cpplint.py" | ||
) | ||
assert not config_file.is_modifiable_file( | ||
"." + os.sep + "wpiformat" + os.sep + "license.txt" | ||
) |
Oops, something went wrong.