Skip to content

Commit

Permalink
Check behavior with GNUC allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Feb 15, 2024
1 parent 1a8dd77 commit 3478bab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def module_from_code(name, python_code):

COUNTER = 0

def generate(header=None, args=[], lang="py", cpp=MAIN_CPP):
def generate(header=None, args=[], lang="py", cpp=MAIN_CPP, allow_gnuc=True):

# Windows notes:
# - Avoid stdlib tempfiles, they're not usable by anyone except the direct creator, otherwise you'll get permission errors.
Expand All @@ -66,6 +66,7 @@ def generate(header=None, args=[], lang="py", cpp=MAIN_CPP):
cmdargs += ["-i", tmp_in]

if cpp: cmdargs += ["--cpp", cpp]
if allow_gnuc: cmdargs += ["-X", "__GNUC__"]
cmdargs += ["--output-language", lang] + args

try:
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,12 +930,12 @@ def test_ordered_passthrough(self):
@requires_gcc
def test_default_undef(self):
# this actually works because the def/undef are taken over into the output, so we won't get a "no target members" exception.
m = generate("", ["--symbol-rules", "yes=__GNUC__"], cpp=f"gcc -E")
m = generate("", ["--symbol-rules", "yes=__GNUC__"], cpp=f"gcc -E", allow_gnuc=False)
self.assertFalse(hasattr(m, "__GNUC__"))

@requires_gcc
def test_override_default_undef(self):
m = generate("", ["-X", "__GNUC__", "--symbol-rules", "yes=__GNUC__"], cpp=f"gcc -E")
m = generate("", ["--symbol-rules", "yes=__GNUC__"], cpp=f"gcc -E", allow_gnuc=True)
self.assertIsInstance(m.__GNUC__, int) # this will be the GCC major version

def test_default_def(self):
Expand Down

0 comments on commit 3478bab

Please sign in to comment.