clean.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env python3
  2. #
  3. # MMGen Wallet, a terminal-based cryptocurrency wallet
  4. # Copyright (C)2013-2025 The MMGen Project <mmgen@tuta.io>
  5. # Licensed under the GNU General Public License, Version 3:
  6. # https://www.gnu.org/licenses
  7. # Public project repositories:
  8. # https://github.com/mmgen/mmgen-wallet
  9. # https://gitlab.com/mmgen/mmgen-wallet
  10. """
  11. test/clean.py: Clean the test directory
  12. """
  13. import sys, os
  14. repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), os.pardir)))
  15. os.chdir(repo_root)
  16. sys.path[0] = repo_root
  17. from mmgen.cfg import Config
  18. opts_data = {
  19. 'text': {
  20. 'desc': 'Clean the test directory',
  21. 'usage':'[options]',
  22. 'options': """
  23. -h, --help Print this help message
  24. --, --longhelp Print help message for long (global) options
  25. """,
  26. },
  27. }
  28. cfg = Config(opts_data=opts_data)
  29. from test.overlay import get_overlay_tree_dir
  30. overlay_tree_dir = get_overlay_tree_dir(repo_root)
  31. if os.path.exists(overlay_tree_dir):
  32. from shutil import rmtree
  33. rmtree(overlay_tree_dir, ignore_errors=True)
  34. print(f'Removed {os.path.relpath(overlay_tree_dir)!r}')
  35. from test.include.common import clean, set_globals
  36. set_globals(cfg)
  37. extra_dirs = [
  38. Config.test_datadir,
  39. os.path.join('test', 'trash'),
  40. os.path.join('test', 'trash2')
  41. ]
  42. from test.cmdtest_d.include.cfg import cfgs
  43. clean(cfgs, extra_dirs=extra_dirs)