-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(aspect): Add test for providing defines via cxxopt
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from platform import system | ||
|
||
from expected_result import ExpectedResult | ||
from test_case import TestCaseBase | ||
|
||
from test.support.result import Result | ||
|
||
|
||
def make_define(flag: str) -> str: | ||
""" | ||
MVSC on Windows has another syntax than gcc and clang | ||
""" | ||
control_character = "/" if system() == "Windows" else "-" | ||
return f"{control_character}D{flag}" | ||
|
||
|
||
class TestCase(TestCaseBase): | ||
def execute_test_logic(self) -> Result: | ||
expected = ExpectedResult(success=True) | ||
actual = self._run_dwyu( | ||
target="//defines:use_command_line_defines", | ||
aspect=self.default_aspect, | ||
extra_args=[f"--cxxopt={make_define('SOME_FLAG')}", f"--cxxopt={make_define('SOME_VALUE=42')}"], | ||
) | ||
|
||
return self._check_result(actual=actual, expected=expected) |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifdef SOME_FLAG | ||
// do some things irrelevant for DWYU | ||
#else | ||
#include "not/extsting/header.h" | ||
#endif | ||
|
||
#if SOME_VALUE > 40 | ||
// do some things irrelevant for DWYU | ||
#else | ||
#include "not/extsting/header.h" | ||
#endif |