clean.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env python3
  2. #
  3. # MMGen Wallet, a terminal-based cryptocurrency wallet
  4. # Copyright (C)2013-2024 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. from test.include.cfg import clean_cfgs
  38. extra_dirs = [
  39. Config.test_datadir,
  40. os.path.join('test', 'trash'),
  41. os.path.join('test', 'trash2')
  42. ]
  43. clean(clean_cfgs, extra_dirs=extra_dirs)