Add more integration tests for update

Summary: I was a little afraid there might be corner cases for the snapshot update optimisation, so I added a bunch more tests on snapshot update, to make sure it always restores the snapshot correctly, regardless of how the working directory state is.

Reviewed By: StanislavGlebik

Differential Revision: D32314413

fbshipit-source-id: 2e42a5fe2eff499fd53a06be110b69eb7c1ad59d
This commit is contained in:
Yan Soares Couto 2021-11-17 08:20:20 -08:00 committed by Facebook GitHub Bot
parent 1afb7aa972
commit b2ed1ed7d2

View File

@ -0,0 +1,57 @@
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# shellcheck source=fbcode/eden/mononoke/tests/integration/library.sh
. "${TEST_FIXTURES}/library.sh"
function base_commit_and_snapshot {
export BASE_SNAPSHOT_COMMIT
# Make an interesting commit and snapshot that tests all types of file changes
echo a > modified_file
echo a > missing_file
echo a > untouched_file
echo a > deleted_file
echo a > deleted_file_then_untracked_modify
hg addremove -q
hg commit -m "Add base files"
BASE_SNAPSHOT_COMMIT=$(hg log -T "{node}" -r .)
EDENSCM_LOG=edenapi::client=error hgedenapi cloud upload -q
# Create snapshot
echo b > modified_file
echo b > untracked_file
echo b > added_file
hg add added_file
echo b > added_file_then_missing
hg add added_file_then_missing
rm added_file_then_missing
rm missing_file
hg rm deleted_file
hg rm deleted_file_then_untracked_modify
echo b > deleted_file_then_untracked_modify
hgedenapi snapshot create
}
BASE_STATUS="\
M modified_file
A added_file
R deleted_file
R deleted_file_then_untracked_modify
! added_file_then_missing
! missing_file
? untracked_file"
function assert_on_base_snapshot {
[[ "$(hg log -T "{node}" -r .)" = "$BASE_SNAPSHOT_COMMIT" ]]
[[ "$(hg st)" = "$BASE_STATUS" ]]
[[ "$(cat modified_file)" = "b" ]]
[[ "$(cat added_file)" = "b" ]]
[[ "$(cat deleted_file_then_untracked_modify)" = "b" ]]
[[ "$(cat untracked_file)" = "b" ]]
[[ ! -f deleted_file ]]
[[ ! -f added_file_then_missing ]]
[[ ! -f missing_file ]]
echo snapshot is correct!
}