test_check_patch_files.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # -*- coding: UTF-8 -*-
  2. # Copyright (c) 2020 The ungoogled-chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """Test check_patch_files.py"""
  6. import logging
  7. import tempfile
  8. import sys
  9. from pathlib import Path
  10. sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent / 'utils'))
  11. from _common import get_logger, set_logging_level
  12. sys.path.pop(0)
  13. sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
  14. from check_patch_files import check_series_duplicates
  15. sys.path.pop(0)
  16. def test_check_series_duplicates():
  17. """Test check_series_duplicates"""
  18. set_logging_level(logging.DEBUG)
  19. with tempfile.TemporaryDirectory() as tmpdirname:
  20. patches_dir = Path(tmpdirname)
  21. series_path = Path(tmpdirname, 'series')
  22. get_logger().info('Check no duplicates')
  23. series_path.write_text('\n'.join([
  24. 'a.patch',
  25. 'b.patch',
  26. 'c.patch',
  27. ]))
  28. assert not check_series_duplicates(patches_dir)
  29. get_logger().info('Check duplicates')
  30. series_path.write_text('\n'.join([
  31. 'a.patch',
  32. 'b.patch',
  33. 'c.patch',
  34. 'a.patch',
  35. ]))
  36. assert check_series_duplicates(patches_dir)
  37. if __name__ == '__main__':
  38. test_check_series_duplicates()