test: disable command line colouring during test-ns3.py tests

This commit is contained in:
Gabriel Ferreira
2022-12-09 19:39:02 -03:00
parent 3a0bd53c7a
commit 1b71af65b3
2 changed files with 8 additions and 4 deletions

3
ns3
View File

@@ -1391,7 +1391,8 @@ def main():
refuse_run_as_root()
# Enable colorized output for CMake and GCC/Clang
os.environ["CLICOLOR"] = "1"
if os.getenv("CLICOLOR") is None:
os.environ["CLICOLOR"] = "1"
# If pybindgen exists in the parent directory
# (e.g. ns3-all-in-one), add it to the PYTHONPATH

View File

@@ -68,6 +68,10 @@ def run_ns3(args, env=None, generator=platform_makefiles):
shutil.rmtree(leftover, ignore_errors=True)
if " -G " in args:
args = args.format(generator=generator)
if env is None:
env = {}
# Disable colored output by default during tests
env["CLICOLOR"] = "0"
return run_program(ns3_script, args, python=True, env=env)
@@ -2662,9 +2666,8 @@ class NS3ExpectedUseTestCase(NS3BaseTestCase):
return_code2, stdout2, stderr2 = run_ns3('run sample-simulator --command-template " "')
return_code3, stdout3, stderr3 = run_ns3('run sample-simulator --command-template "echo "')
self.assertEqual((return_code1, return_code2, return_code3), (1, 1, 1))
self.assertIn("not all arguments converted during string formatting", stderr1)
self.assertEqual(stderr1, stderr2)
self.assertEqual(stderr2, stderr3)
for stderr in [stderr1, stderr2, stderr3]:
self.assertIn("not all arguments converted during string formatting", stderr)
# Command templates with %s should at least continue and try to run the target
return_code4, stdout4, _ = run_ns3('run sample-simulator --command-template "%s --PrintVersion" --verbose')