Skip to content

Commit

Permalink
Add test for multi-dir merging
Browse files Browse the repository at this point in the history
  • Loading branch information
gliargovas committed Oct 11, 2023
1 parent ea744b1 commit 15e20ac
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions test/merge_multiple_dirs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/sh

TRY_TOP="${TRY_TOP:-$(git rev-parse --show-toplevel --show-superproject-working-tree)}"
TRY="$TRY_TOP/try"

cleanup() {
cd /

if [ -d "$try_workspace" ]
then
rm -rf "$try_workspace" >/dev/null 2>&1
fi

if [ -f "$try_example_dir1" ]
then
rm "$try_example_dir1"
fi

if [ -f "$try_example_dir2" ]
then
rm "$try_example_dir2"
fi

if [ -f "$try_example_dir3" ]
then
rm "$try_example_dir3"
fi

if [ -f "$expected1" ]
then
rm "$expected1"
fi

if [ -f "$expected2" ]
then
rm "$expected2"
fi

if [ -f "$expected3" ]
then
rm "$expected3"
fi

if [ -f "$expected4" ]
then
rm "$expected4"
fi
}

trap 'cleanup' EXIT

try_workspace="$(mktemp -d -p .)"
cp "$TRY_TOP/test/resources/file.txt.gz" "$try_workspace/"
cd $try_workspace

try_example_dir1="$(mktemp -d)"
try_example_dir2="$(mktemp -d)"
try_example_dir3="$(mktemp -d)"

expected1="$(mktemp)"
expected2="$(mktemp)"
expected3="$(mktemp)"

touch "$expected1"
echo "test2" > $expected2
echo "test3" > $expected3

"$TRY" -D "$try_example_dir1" "touch file_1.txt; echo test > file_2.txt; rm file.txt.gz" || return 1
"$TRY" -D "$try_example_dir2" "echo test2 > file_2.txt" || return 2
"$TRY" -D "$try_example_dir3" "echo test3 > file_3.txt" || return 3
"$TRY" -L "$try_example_dir3:$try_example_dir2:$try_example_dir1" -y "cat file_1.txt > out1; cat file_2.txt > out2; cat file_3.txt > out3"|| return 4

diff -q "$expected1" out1 || return 5
diff -q "$expected2" out2 || return 6
diff -q "$expected3" out3 || return 7

! [ -f out4 ] || return 8

0 comments on commit 15e20ac

Please sign in to comment.