From 0f7b5fbae63e3486255b2b9951373075d55a9a58 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 10 Feb 2023 12:06:40 -0700 Subject: Adjust CPPDEFINES tests to be more resilient In a hope to make the tests runnable against a checkout that does not include PR #4263, add some try blocks so the things which used to blow up can generate errors rather than aborting the test run. The prepend test still fails against master. Signed-off-by: Mats Wichmann --- test/CPPDEFINES/fixture/SConstruct-Append | 27 +++++++++++++++++---------- test/CPPDEFINES/fixture/SConstruct-Prepend | 27 +++++++++++++++++---------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/test/CPPDEFINES/fixture/SConstruct-Append b/test/CPPDEFINES/fixture/SConstruct-Append index df47f68..62d7352 100644 --- a/test/CPPDEFINES/fixture/SConstruct-Append +++ b/test/CPPDEFINES/fixture/SConstruct-Append @@ -96,16 +96,23 @@ for (t1, c1) in cases: for (t2, c2) in cases: print(f"==== Testing CPPDEFINES, appending a {t2} to a {t1}") # string-like appearance if the value is a string - orig = f"'{c1}'" if isinstance(c1, str) else c1 - app = f"'{c2}'" if isinstance(c2, str) else c2 + orig = f"{c1!r}" if isinstance(c1, str) else c1 + app = f"{c2!r}" if isinstance(c2, str) else c2 print(f" orig = {orig}, append = {app}") env = Environment(CPPDEFINES=c1, CPPDEFPREFIX='-D') - env.Append(CPPDEFINES=c2) - final = env.subst('$_CPPDEFFLAGS', source="src", target="tgt") - print(f"Append:\n result={dlist(env['CPPDEFINES'])}\n final={final}") + try: + env.Append(CPPDEFINES=c2) + final = env.subst('$_CPPDEFFLAGS', source="src", target="tgt") + print(f"Append:\n result={dlist(env['CPPDEFINES'])}\n final={final}") + except Exception as t: + print(f"Append:\n FAILED: {t}") + env = Environment(CPPDEFINES=c1, CPPDEFPREFIX='-D') - env.AppendUnique(CPPDEFINES=c2) - final = env.subst('$_CPPDEFFLAGS', source="src", target="tgt") - print( - f"AppendUnique:\n result={dlist(env['CPPDEFINES'])}\n final={final}" - ) + try: + env.AppendUnique(CPPDEFINES=c2) + final = env.subst('$_CPPDEFFLAGS', source="src", target="tgt") + print( + f"AppendUnique:\n result={dlist(env['CPPDEFINES'])}\n final={final}" + ) + except Exception as t: + print(f"AppendUnique:\n FAILED: {t}") diff --git a/test/CPPDEFINES/fixture/SConstruct-Prepend b/test/CPPDEFINES/fixture/SConstruct-Prepend index 7fd4d84..4234de2 100644 --- a/test/CPPDEFINES/fixture/SConstruct-Prepend +++ b/test/CPPDEFINES/fixture/SConstruct-Prepend @@ -97,16 +97,23 @@ for (t1, c1) in cases: for (t2, c2) in cases: print(f"==== Testing CPPDEFINES, prepending a {t2} to a {t1}") # string-like appearance if the value is a string - orig = f"'{c1}'" if isinstance(c1, str) else c1 - pre = f"'{c2}'" if isinstance(c2, str) else c2 + orig = f"{c1!r}" if isinstance(c1, str) else c1 + pre = f"{c2!r}" if isinstance(c2, str) else c2 print(f" orig = {orig}, prepend = {pre}") env = Environment(CPPDEFINES=c1, CPPDEFPREFIX='-D') - env.Prepend(CPPDEFINES=c2) - final = env.subst('$_CPPDEFFLAGS', source="src", target="tgt") - print(f"Prepend:\n result={dlist(env['CPPDEFINES'])}\n final={final}") + try: + env.Prepend(CPPDEFINES=c2) + final = env.subst('$_CPPDEFFLAGS', source="src", target="tgt") + print(f"Prepend:\n result={dlist(env['CPPDEFINES'])}\n final={final}") + except Exception as t: + print(f"Prepend:\n FAILED: {t}") + env = Environment(CPPDEFINES=c1, CPPDEFPREFIX='-D') - env.PrependUnique(CPPDEFINES=c2) - final = env.subst('$_CPPDEFFLAGS', source="src", target="tgt") - print( - f"PrependUnique:\n result={dlist(env['CPPDEFINES'])}\n final={final}" - ) + try: + env.PrependUnique(CPPDEFINES=c2) + final = env.subst('$_CPPDEFFLAGS', source="src", target="tgt") + print( + f"PrependUnique:\n result={dlist(env['CPPDEFINES'])}\n final={final}" + ) + except Exception as t: + print(f"PrependUnique:\n FAILED: {t}") -- cgit v0.12