From a4468f5772e97022a694240a73ad8b745d743558 Mon Sep 17 00:00:00 2001 From: Fabrice Renard Date: Tue, 26 Mar 2024 23:15:29 -0400 Subject: [PATCH] Complete update-checkout stash test https://github.com/apple/swift/issues/72523 --- utils/update_checkout/tests/test_stash.py | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 utils/update_checkout/tests/test_stash.py diff --git a/utils/update_checkout/tests/test_stash.py b/utils/update_checkout/tests/test_stash.py new file mode 100644 index 0000000000000..55bd6f9195897 --- /dev/null +++ b/utils/update_checkout/tests/test_stash.py @@ -0,0 +1,42 @@ +# ===--- test_stash.py -----------------------------------------------------===# +# +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2024 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See https:#swift.org/LICENSE.txt for license information +# See https:#swift.org/CONTRIBUTORS.txt for the list of Swift project authors +# +# ===----------------------------------------------------------------------===# + +from . import scheme_mock +import os + +class StashTestCase(scheme_mock.SchemeMockTestCase): + def __init__(self, *args, **kwargs): + super(StashTestCase, self).__init__(*args, **kwargs) + + def test_stash_untracked_files(self): + self.call([self.update_checkout_path, + '--config', self.config_path, + '--source-root', self.source_root, + '--clone']) + + for repo in self.get_all_repos(): + repo_path = os.path.join(self.source_root, repo) + with open(os.path.join(repo_path, 'untracked_file.txt'), 'w') as f: + f.write('This is an untracked file.') + + self.call([self.update_checkout_path, + '--config', self.config_path, + '--source-root', self.source_root, + '--stash']) + + for repo in self.get_all_repos(): + repo_path = os.path.join(self.source_root, repo) + untracked_file_path = os.path.join(repo_path, 'untracked_file.txt') + self.assertFalse( + os.path.exists(untracked_file_path), + f"{untracked_file_path} should be stashed and not present in the working directory." + )