Mercurial > p > roundup > code
comparison test/test_admin.py @ 7254:af870e295b46
add test for pragma _reopen_tracker
missed committing it with the code change.
Note _reopen_tracker is a negative feature flag. It should go away if
nobody reports an error with the new tracker open caching code path.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 12 Apr 2023 21:02:28 -0400 |
| parents | 9c067ed4568b |
| children | bd6523c84a95 |
comparison
equal
deleted
inserted
replaced
| 7253:393ae88bf7b1 | 7254:af870e295b46 |
|---|---|
| 800 | 800 |
| 801 out = out.getvalue().strip() | 801 out = out.getvalue().strip() |
| 802 print("me: " + out) | 802 print("me: " + out) |
| 803 print(err.getvalue().strip()) | 803 print(err.getvalue().strip()) |
| 804 self.assertEqual(out, "issue1:issue2") | 804 self.assertEqual(out, "issue1:issue2") |
| 805 | |
| 806 def testPragma_reopen_tracker(self): | |
| 807 """test that _reopen_tracker works. | |
| 808 """ | |
| 809 if self.backend not in ['anydbm']: | |
| 810 self.skipTest("For speed only run test with anydbm.") | |
| 811 | |
| 812 orig_input = AdminTool.my_input | |
| 813 | |
| 814 # must set verbose to see _reopen_tracker hidden setting. | |
| 815 # and to get "Reopening tracker" verbose log output | |
| 816 inputs = iter(["pragma verbose=true", "pragma list", "quit"]) | |
| 817 AdminTool.my_input = lambda _self, _prompt: next(inputs) | |
| 818 | |
| 819 self.install_init() | |
| 820 self.admin=AdminTool() | |
| 821 sys.argv=['main', '-i', self.dirname] | |
| 822 | |
| 823 with captured_output() as (out, err): | |
| 824 ret = self.admin.main() | |
| 825 | |
| 826 out = out.getvalue().strip().split('\n') | |
| 827 | |
| 828 print(ret) | |
| 829 self.assertTrue(ret == 0) | |
| 830 expected = ' _reopen_tracker=False' | |
| 831 self.assertIn(expected, out) | |
| 832 self.assertIn('descriptions...', out[-1]) | |
| 833 self.assertNotIn('Reopening tracker', out) | |
| 834 | |
| 835 # ----- | |
| 836 inputs = iter(["pragma verbose=true", "pragma _reopen_tracker=True", | |
| 837 "pragma list", "quit"]) | |
| 838 AdminTool.my_input = lambda _self, _prompt: next(inputs) | |
| 839 | |
| 840 self.install_init() | |
| 841 self.admin=AdminTool() | |
| 842 sys.argv=['main', '-i', self.dirname] | |
| 843 | |
| 844 with captured_output() as (out, err): | |
| 845 ret = self.admin.main() | |
| 846 | |
| 847 out = out.getvalue().strip().split('\n') | |
| 848 | |
| 849 print(ret) | |
| 850 self.assertTrue(ret == 0) | |
| 851 self.assertEqual('Reopening tracker', out[2]) | |
| 852 expected = ' _reopen_tracker=True' | |
| 853 self.assertIn(expected, out) | |
| 854 | |
| 855 # ----- | |
| 856 AdminTool.my_input = orig_input | |
| 805 | 857 |
| 806 def testPragma(self): | 858 def testPragma(self): |
| 807 """Uses interactive mode since pragmas only apply when using multiple | 859 """Uses interactive mode since pragmas only apply when using multiple |
| 808 commands. | 860 commands. |
| 809 """ | 861 """ |
