diff --git a/t/smoke-test.branchmap b/t/smoke-test.branchmap new file mode 100644 index 0000000..10f2d57 --- /dev/null +++ b/t/smoke-test.branchmap @@ -0,0 +1,15 @@ +"feature"="renamed-feature" +"a?"="valid-0" +"a/"="valid-1" +"a/b"="valid-2" +"a/?"="valid-3" +"?a"="valid-4" +"a."="valid-5" +"a.b"="valid-6" +".a"="valid-7" +"/"="valid-8" +"___3"="___a" +"__2"="__b" +"_1"="_c" +"åäö"="abc" +"Feature- 12V Vac \"Venom\""="venom" diff --git a/t/smoke-test.expected b/t/smoke-test.expected new file mode 100644 index 0000000..8b95e68 --- /dev/null +++ b/t/smoke-test.expected @@ -0,0 +1,280 @@ +blob +mark :1 +data 5 +r0-a + +blob +mark :2 +data 5 +r0-b + +reset refs/heads/master +commit refs/heads/master +mark :3 +author Grevious Bodily Harmsworth 1679014800 +0000 +committer Grevious Bodily Harmsworth 1679014800 +0000 +data 2 +r0M 100644 :1 a.txt +M 100644 :2 b.txt + +blob +mark :4 +data 5 +r1-c + +blob +mark :5 +data 5 +r1-d + +commit refs/tags/2019_Spring_R2 +mark :6 +author Grevious Bodily Harmsworth 1679018400 +0000 +committer Grevious Bodily Harmsworth 1679018400 +0000 +data 2 +r1from :3 +M 100644 :4 c.txt +M 100644 :5 d.txt + +blob +mark :7 +data 56 +e92e41dde44f9dbbac08bbb83351a65b6728f128 2019 Spring R2 + +commit refs/heads/mainline +mark :8 +author Grevious Bodily Harmsworth 1679019000 +0000 +committer Grevious Bodily Harmsworth 1679019000 +0000 +data 51 +Added tag 2019 Spring R2 for changeset e92e41dde44ffrom :6 +M 100644 :7 .hgtags + +blob +mark :9 +data 5 +r2-e + +blob +mark :10 +data 5 +r2-f + +commit refs/heads/mainline +mark :11 +author Grevious Bodily Harmsworth 1679022000 +0000 +committer Grevious Bodily Harmsworth 1679022000 +0000 +data 2 +r2from :8 +M 100644 :9 e.txt +M 100644 :10 f.txt + +commit refs/heads/mainline +mark :12 +author badly-formed-user 1679025600 +0000 +committer badly-formed-user 1679025600 +0000 +data 2 +r3from :11 +M 100644 :9 g.txt +M 100644 :10 h.txt + +blob +mark :13 +data 10 +feature-a + +blob +mark :14 +data 10 +feature-b + +commit refs/heads/renamed-feature +mark :15 +author Grevious Bodily Harmsworth 1679029200 +0000 +committer Grevious Bodily Harmsworth 1679029200 +0000 +data 7 +featurefrom :12 +M 100644 :13 feature-a.txt +M 100644 :14 feature-b.txt + +blob +mark :16 +data 3 +a? + +commit refs/heads/valid-0 +mark :17 +author Grevious Bodily Harmsworth 1679032800 +0000 +committer Grevious Bodily Harmsworth 1679032800 +0000 +data 23 +Added file in branch a?from :15 +M 100644 :16 c1086ce03e4f52aadd1c93b1d097da510138522a + +blob +mark :18 +data 3 +a/ + +commit refs/heads/valid-1 +mark :19 +author Grevious Bodily Harmsworth 1679036400 +0000 +committer Grevious Bodily Harmsworth 1679036400 +0000 +data 23 +Added file in branch a/from :17 +M 100644 :18 85ed6fbb96d655df9f194bc9107f2d86210b9263 + +blob +mark :20 +data 4 +a/b + +commit refs/heads/valid-2 +mark :21 +author Grevious Bodily Harmsworth 1679040000 +0000 +committer Grevious Bodily Harmsworth 1679040000 +0000 +data 24 +Added file in branch a/bfrom :19 +M 100644 :20 aae42d317509399fdda80c4d8e46774d152dbd04 + +blob +mark :22 +data 4 +a/? + +commit refs/heads/valid-3 +mark :23 +author Grevious Bodily Harmsworth 1679043600 +0000 +committer Grevious Bodily Harmsworth 1679043600 +0000 +data 24 +Added file in branch a/?from :21 +M 100644 :22 ba54a8de7fe91c5e6e0a2dd1b9b37de0976ff5a7 + +blob +mark :24 +data 3 +?a + +commit refs/heads/valid-4 +mark :25 +author Grevious Bodily Harmsworth 1679047200 +0000 +committer Grevious Bodily Harmsworth 1679047200 +0000 +data 23 +Added file in branch ?afrom :23 +M 100644 :24 d4cde16119b586025976741e87775762a2598984 + +blob +mark :26 +data 3 +a. + +commit refs/heads/valid-5 +mark :27 +author Grevious Bodily Harmsworth 1679050800 +0000 +committer Grevious Bodily Harmsworth 1679050800 +0000 +data 23 +Added file in branch a.from :25 +M 100644 :26 b4ce96ddcee0706a8c51130917f910b2b29faf77 + +blob +mark :28 +data 4 +a.b + +commit refs/heads/valid-6 +mark :29 +author Grevious Bodily Harmsworth 1679054400 +0000 +committer Grevious Bodily Harmsworth 1679054400 +0000 +data 24 +Added file in branch a.bfrom :27 +M 100644 :28 97051191e1a92daa11165ef10770bf964268c58b + +blob +mark :30 +data 3 +.a + +commit refs/heads/valid-7 +mark :31 +author Grevious Bodily Harmsworth 1679058000 +0000 +committer Grevious Bodily Harmsworth 1679058000 +0000 +data 23 +Added file in branch .afrom :29 +M 100644 :30 a667f8feec02fdfa6649772f844a24cf1ad5ebec + +blob +mark :32 +data 2 +/ + +commit refs/heads/valid-8 +mark :33 +author Grevious Bodily Harmsworth 1679061600 +0000 +committer Grevious Bodily Harmsworth 1679061600 +0000 +data 22 +Added file in branch /from :31 +M 100644 :32 8f27084b6294ddbe28dbcbf98f798730e8a79289 + +blob +mark :34 +data 5 +___3 + +commit refs/heads/___a +mark :35 +author Grevious Bodily Harmsworth 1679065200 +0000 +committer Grevious Bodily Harmsworth 1679065200 +0000 +data 25 +Added file in branch ___3from :33 +M 100644 :34 9b171494eb6e5ce325934b1656e286ca0510a697 + +blob +mark :36 +data 4 +__2 + +commit refs/heads/__b +mark :37 +author Grevious Bodily Harmsworth 1679068800 +0000 +committer Grevious Bodily Harmsworth 1679068800 +0000 +data 24 +Added file in branch __2from :35 +M 100644 :36 5dca703b71d2613c6bb3262b9b1741d6165e4a2f + +blob +mark :38 +data 3 +_1 + +commit refs/heads/_c +mark :39 +author Grevious Bodily Harmsworth 1679072400 +0000 +committer Grevious Bodily Harmsworth 1679072400 +0000 +data 23 +Added file in branch _1from :37 +M 100644 :38 2fee90e148a2afbd911b67ced9b6240151f904ec + +blob +mark :40 +data 25 +Feature- 12V Vac "Venom" + +commit refs/heads/venom +mark :41 +author Grevious Bodily Harmsworth 1679076000 +0000 +committer Grevious Bodily Harmsworth 1679076000 +0000 +data 45 +Added file in branch Feature- 12V Vac "Venom"from :39 +M 100644 :40 b01def8779aed4be2f4b7325a89992a9aa566fec + +blob +mark :42 +data 7 +åäö + +commit refs/heads/abc +mark :43 +author Grevious Bodily Harmsworth 1679079600 +0000 +committer Grevious Bodily Harmsworth 1679079600 +0000 +data 27 +Added file in branch åäöfrom :41 +M 100644 :42 a0d01fcbff5d86327d542687dcfd8b299d054147 + diff --git a/t/smoke-test.t b/t/smoke-test.t new file mode 100755 index 0000000..5bda86a --- /dev/null +++ b/t/smoke-test.t @@ -0,0 +1,162 @@ +#!/bin/bash +# +# Copyright (c) 2023 Felipe Contreras +# Copyright (c) 2023 Frej Drejhammar +# +# Smoke test used to sanity test changes to fast-export. +# + +test_description='Smoke test' + +. "${SHARNESS_TEST_SRCDIR-/usr/share/sharness}"/sharness.sh || exit 1 + +check() { + echo "$3" > expected && + git -C "$1" show -q --format='%s' "$2" > actual && + test_cmp expected actual +} + +git_create() { + git init -q "$1" +} + +git_convert() { + ( + cd "$2" && + hg-fast-export.sh --repo "../$1" \ + -s --hgtags -n \ + -B "$SHARNESS_TEST_DIRECTORY"/smoke-test.branchmap \ + -T "$SHARNESS_TEST_DIRECTORY"/smoke-test.tagsmap + ) +} + +setup() { + cat > "$HOME"/.hgrc <<-EOF + [ui] + username = Grevious Bodily Harmsworth + EOF +} + +commit0() { + ( + cd hgrepo && + echo "r0-a" > a.txt && + echo "r0-b" > b.txt && + hg add a.txt b.txt && + hg commit -d "2023-03-17 01:00Z" -m "r0" && + hg bookmark bm0 + ) +} + +commit1() { + ( + cd hgrepo && + echo "r1-c" > c.txt && + echo "r1-d" > d.txt && + hg branch mainline && + hg add c.txt d.txt && + hg commit -d "2023-03-17 02:00Z" -m "r1" && + hg tag -d "2023-03-17 02:10Z" "2019 Spring R2" + ) +} + +commit2() { + ( + cd hgrepo && + echo "r2-e" > e.txt && + echo "r2-f" > f.txt && + hg add e.txt f.txt && + hg commit -d "2023-03-17 03:00Z" -m "r2" && + hg bookmark bm1 + ) +} + +commit3() { + ( + cd hgrepo && + echo "r2-e" > g.txt && + echo "r2-f" > h.txt && + hg add g.txt h.txt && + hg commit -d "2023-03-17 04:00Z" -u "badly-formed-user" -m "r3" + ) +} + +commit_rest() { + ( + cd hgrepo && + + hg branch feature && + echo "feature-a" > feature-a.txt && + echo "feature-b" > feature-b.txt && + hg add feature-a.txt feature-b.txt && + hg commit -d "2023-03-17 05:00Z" -m "feature" && + hg bookmark bm2 && + + # Now create strangely named branches + make-branch "a?" 06 && + make-branch "a/" 07 && + make-branch "a/b" 08 && + make-branch "a/?" 09 && + make-branch "?a" 10 && + make-branch "a." 11 && + make-branch "a.b" 12 && + make-branch ".a" 13 && + make-branch "/" 14 && + make-branch "___3" 15 && + make-branch "__2" 16 && + make-branch "_1" 17 && + make-branch "Feature- 12V Vac \"Venom\"" 18 && + make-branch "åäö" 19 && + + hg bookmark bm-for-the-rest + ) +} + +make-branch() { + hg branch "$1" + FILE=$(echo "$1" | sha1sum | cut -d " " -f 1) + echo "$1" > $FILE + hg add $FILE + hg commit -d "2023-03-17 $2:00Z" -m "Added file in branch $1" +} + +setup + +test_expect_success 'all in one' ' + test_when_finished "rm -rf hgrepo gitrepo" && + + ( + hg init hgrepo && + commit0 && + commit1 && + commit2 && + commit3 && + commit_rest + ) && + git_create gitrepo && + git_convert hgrepo gitrepo && + git -C gitrepo fast-export --all > actual && + + test_cmp "$SHARNESS_TEST_DIRECTORY"/smoke-test.expected actual +' + +test_expect_success 'incremental' ' + test_when_finished "rm -rf hgrepo gitrepo" && + + hg init hgrepo && + commit0 && + git_create gitrepo && + git_convert hgrepo gitrepo && + commit1 && + git_convert hgrepo gitrepo && + commit2 && + commit3 && + git_convert hgrepo gitrepo && + commit_rest && + git_convert hgrepo gitrepo && + git -C gitrepo fast-export --all > actual && + + test_cmp "$SHARNESS_TEST_DIRECTORY"/smoke-test.expected actual +' + +test_done diff --git a/t/smoke-test.tagsmap b/t/smoke-test.tagsmap new file mode 100644 index 0000000..98868dc --- /dev/null +++ b/t/smoke-test.tagsmap @@ -0,0 +1 @@ +"2019 Spring R2"="2019_Spring_R2"