Skip to content

Complete update-checkout stash test #72823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions utils/update_checkout/tests/test_stash.py
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2024 → 2025

# 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."
)