clean.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, a command-line 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. from mmgen.cfg import Config
  15. opts_data = {
  16. 'text': {
  17. 'desc': 'Clean the test directory',
  18. 'usage':'[options]',
  19. 'options': """
  20. -h, --help Print this help message
  21. --, --longhelp Print help message for long options (common options)
  22. """,
  23. },
  24. }
  25. cfg = Config(opts_data=opts_data)
  26. repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), os.pardir)))
  27. os.chdir(repo_root)
  28. sys.path[0] = repo_root
  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. data_dir = Config.test_datadir
  39. trash_dir = os.path.join('test', 'trash')
  40. trash_dir2 = os.path.join('test', 'trash2')
  41. clean(clean_cfgs, extra_dirs=[data_dir, trash_dir, trash_dir2])