This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
neels gerrit-no-reply at lists.osmocom.orgneels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-gsm-tester/+/21541 ) Change subject: fix: line nr in test name in wrong places ...................................................................... fix: line nr in test name in wrong places test.Test() overrides name() in order to provide source line number information. However, overriding name() is the wrong place for that, as name() is also often used for identifying an object - when listing the tests of a suite, the line number should not appear in the test name. For example, the line number sometimes ends up in the test results in jenkins, making 'foo.py' and 'foo.py:23' two distinct report items. Instead, add a separate function Origin.src() that defaults to name(), but specific classes can override src() if they wish to provide more detailed information with the object name. Override src() in Test, not name(). Use src() in backtraces. The suite_test.ok shows that the backtracing in the log remains unchanged, but the place where the test name is printed is corrected: I am 'test_suite' / 'hello_world.py:23' becomes I am 'test_suite' / 'hello_world.py' (Notice that "[LINENR]" in suite_test.ok is a masking of an actual number, done within the selftest suite) Change-Id: I0c4698fa2b3db3de777d8b6dcdcee84e433c62b7 --- M selftest/suite_test/suite_test.ok M src/osmo_gsm_tester/core/log.py M src/osmo_gsm_tester/core/test.py 3 files changed, 17 insertions(+), 11 deletions(-) Approvals: pespin: Looks good to me, approved diff --git a/selftest/suite_test/suite_test.ok b/selftest/suite_test/suite_test.ok index dfc8d41..2c49c19 100644 --- a/selftest/suite_test/suite_test.ok +++ b/selftest/suite_test/suite_test.ok @@ -160,7 +160,7 @@ trial test_suite hello_world.py ---------------------------------------------- tst hello_world.py:[LINENR]: hello world [test_suite↪hello_world.py:[LINENR]] -tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py:[LINENR]' [test_suite↪hello_world.py:[LINENR]] +tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py' [test_suite↪hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: one [test_suite↪hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: two [test_suite↪hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: three [test_suite↪hello_world.py:[LINENR]] @@ -187,7 +187,7 @@ ---------------------------------------------- trial test_suite test_error.py ---------------------------------------------- -tst test_error.py:[LINENR]: I am 'test_suite' / 'test_error.py:[LINENR]' [test_suite↪test_error.py:[LINENR]] [test_error.py:[LINENR]] +tst test_error.py:[LINENR]: I am 'test_suite' / 'test_error.py' [test_suite↪test_error.py:[LINENR]] [test_error.py:[LINENR]] tst test_error.py:[LINENR]: ERR: AssertionError: test_error.py:[LINENR]: assert False [test_suite↪test_error.py:[LINENR]] [test_error.py:[LINENR]: assert False] tst test_error.py:[LINENR]: Test FAILED (N.N sec) [test_suite↪test_error.py:[LINENR]] [test.py:[LINENR]] --------------------------------------------------------------------- @@ -212,7 +212,7 @@ ---------------------------------------------- trial test_suite test_fail.py ---------------------------------------------- -tst test_fail.py:[LINENR]: I am 'test_suite' / 'test_fail.py:[LINENR]' [test_suite↪test_fail.py:[LINENR]] [test_fail.py:[LINENR]] +tst test_fail.py:[LINENR]: I am 'test_suite' / 'test_fail.py' [test_suite↪test_fail.py:[LINENR]] [test_fail.py:[LINENR]] tst test_fail.py:[LINENR]: ERR: EpicFail: This failure is expected [test_suite↪test_fail.py:[LINENR]] [test_fail.py:[LINENR]] tst test_fail.py:[LINENR]: Test FAILED (N.N sec) [test_suite↪test_fail.py:[LINENR]] [test.py:[LINENR]] --------------------------------------------------------------------- @@ -389,7 +389,7 @@ trial test_suite hello_world.py ---------------------------------------------- tst hello_world.py:[LINENR]: hello world [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] -tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py:[LINENR]' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] +tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: one [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: two [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: three [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] @@ -544,7 +544,7 @@ trial test_suite hello_world.py ---------------------------------------------- tst hello_world.py:[LINENR]: hello world [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] -tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py:[LINENR]' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] +tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: one [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: two [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: three [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] @@ -745,7 +745,7 @@ trial test_suite hello_world.py ---------------------------------------------- tst hello_world.py:[LINENR]: hello world [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] -tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py:[LINENR]' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] +tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py' [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: one [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: two [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] tst hello_world.py:[LINENR]: three [test_suite↪hello_world.py:[LINENR]] [hello_world.py:[LINENR]] diff --git a/src/osmo_gsm_tester/core/log.py b/src/osmo_gsm_tester/core/log.py index b8182f5..2b8db62 100644 --- a/src/osmo_gsm_tester/core/log.py +++ b/src/osmo_gsm_tester/core/log.py @@ -222,7 +222,7 @@ if origin is None: name = '-' elif isinstance(origin, Origin): - name = origin.name() + name = origin.src() # only log ancestry when there is more than one if origin._parent is not None: deeper_origins = origin.ancestry_str() @@ -447,6 +447,12 @@ def name(self): return self._name or self.__class__.__name__ + def src(self): + '''subclasses may override this to provide more detailed source + information with the name, for a backtrace. For example, a line number + in a test script.''' + return self.name() + __str__ = name __repr__ = name @@ -476,7 +482,7 @@ return origins def ancestry_str(self): - return '↪'.join([o.name() for o in self.ancestry()]) + return '↪'.join([o.src() for o in self.ancestry()]) def highest_ancestor(self): if self._parent: diff --git a/src/osmo_gsm_tester/core/test.py b/src/osmo_gsm_tester/core/test.py index fd3ac04..896eb4c 100644 --- a/src/osmo_gsm_tester/core/test.py +++ b/src/osmo_gsm_tester/core/test.py @@ -102,11 +102,11 @@ for log_tgt in self.log_targets: log_tgt.remove() - def name(self): + def src(self): l = log.get_line_for_src(self.path) if l is not None: - return '%s:%s' % (self._name, l) - return super().name() + return '%s:%s' % (self.name(), l) + return self.name() def elapsed_time(self): 'time elapsed since test was started' -- To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/21541 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-gsm-tester Gerrit-Branch: master Gerrit-Change-Id: I0c4698fa2b3db3de777d8b6dcdcee84e433c62b7 Gerrit-Change-Number: 21541 Gerrit-PatchSet: 3 Gerrit-Owner: neels <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin at sysmocom.de> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201210/d1c7f0ad/attachment.htm>