Skip to content

Commit 8a8832c

Browse files
author
Thomas Preud'homme
committed
[LNT] Python 3 support: fix server/ui/statsTester.py test discovery
Summary: Unit test server/ui/statsTester.py is invoked with an extra parameter which confuses unittest test discovery. Indeed, when parameter defaultTest of unittest.main() method is in its default value the test to run is taken from argv parameter if not empty. argv parameter in turn defaults to sys.argv and thus unittest will take the first parameter for the name of the test to execute. Under Python 2 this would throw an AttributeError which would pass through all the way up to the test itself which contains a catch to remove the parameter and try again. Note that the exception is not documented. Under Python 3 the exception is caught by the unittest framework which exits with an error. Since the parameter that confuses the test discovery is a temporary LNT instance directory which is not used by the test, this commit simply removes these LIT steps and only call the unittest without parameter. Reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls, leandron, PrzemekWirkus Reviewed By: PrzemekWirkus Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D68921
1 parent 8ff573a commit 8a8832c

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

tests/server/ui/statsTester.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
#
2-
# create temporary instance
3-
# Cleanup temporary directory in case one remained from a previous run - also
4-
# see PR9904.
5-
# RUN: rm -rf %t.instance
6-
# RUN: python %{shared_inputs}/create_temp_instance.py \
7-
# RUN: %s %{shared_inputs}/SmallInstance %t.instance \
8-
# RUN: %S/Inputs/V4Pages_extra_records.sql
9-
#
10-
# RUN: python %s %t.instance
1+
# RUN: python %s
112

123
import unittest
134

@@ -54,13 +45,4 @@ def test_agg_mean(self):
5445

5546

5647
if __name__ == '__main__':
57-
try:
58-
unittest.main()
59-
except AttributeError:
60-
# Command line parameters are treated as test cases, when \
61-
# running with lit rather than python directly.
62-
import sys
63-
if len(sys.argv) != 2:
64-
sys.exit("Something went horribly wrong. You need parameters.")
65-
del sys.argv[1:]
66-
unittest.main()
48+
unittest.main()

0 commit comments

Comments
 (0)