From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johan Herland Subject: [RFC/PATCHv8 10/10] Add more testcases to test fast-import of notes Date: Fri, 20 Nov 2009 02:39:14 +0100 Message-ID: <1258681154-2167-11-git-send-email-johan@herland.net> References: <1258681154-2167-1-git-send-email-johan@herland.net> Mime-Version: 1.0 Content-Type: TEXT/PLAIN Content-Transfer-Encoding: 7BIT Cc: gitster@pobox.com, johan@herland.net, spearce@spearce.org To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Fri Nov 20 02:40:25 2009 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1NBIU5-0004ED-50 for gcvg-git-2@lo.gmane.org; Fri, 20 Nov 2009 02:40:25 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757486AbZKTBjy (ORCPT ); Thu, 19 Nov 2009 20:39:54 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757480AbZKTBjw (ORCPT ); Thu, 19 Nov 2009 20:39:52 -0500 Received: from smtp.getmail.no ([84.208.15.66]:58338 "EHLO get-mta-out01.get.basefarm.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757420AbZKTBjr (ORCPT ); Thu, 19 Nov 2009 20:39:47 -0500 Received: from smtp.getmail.no ([10.5.16.4]) by get-mta-out01.get.basefarm.net (Sun Java(tm) System Messaging Server 7.0-0.04 64bit (built Jun 20 2008)) with ESMTP id <0KTD00MOJWMGSE10@get-mta-out01.get.basefarm.net> for git@vger.kernel.org; Fri, 20 Nov 2009 02:39:52 +0100 (MET) Received: from localhost.localdomain ([84.215.102.95]) by get-mta-in02.get.basefarm.net (Sun Java(tm) System Messaging Server 7.0-0.04 64bit (built Jun 20 2008)) with ESMTP id <0KTD00D7NWLXUY10@get-mta-in02.get.basefarm.net> for git@vger.kernel.org; Fri, 20 Nov 2009 02:39:52 +0100 (MET) X-PMX-Version: 5.5.3.366731, Antispam-Engine: 2.7.0.366912, Antispam-Data: 2009.11.20.12721 X-Mailer: git-send-email 1.6.4.304.g1365c.dirty In-reply-to: <1258681154-2167-1-git-send-email-johan@herland.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: This patch adds testcases verifying correct behaviour in several scenarios regarding fast-import of notes: - using a mixture of 'N' and 'M' commands - updating existing notes - concatenation of notes - 'deleteall' also removes notes - fanout schemes is added/removed when needed - git-fast-import's branch unload/reload preserves notes Signed-off-by: Johan Herland --- t/t9301-fast-import-notes.sh | 578 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 578 insertions(+), 0 deletions(-) create mode 100755 t/t9301-fast-import-notes.sh diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh new file mode 100755 index 0000000..5a08a76 --- /dev/null +++ b/t/t9301-fast-import-notes.sh @@ -0,0 +1,578 @@ +#!/bin/sh +# +# Copyright (c) 2009 Johan Herland +# + +test_description='test git fast-import of notes objects' +. ./test-lib.sh + + +test_tick +cat >input < $GIT_COMMITTER_DATE +data < $GIT_COMMITTER_DATE +data < $GIT_COMMITTER_DATE +data < $GIT_COMMITTER_DATE +data <input < $GIT_COMMITTER_DATE +data <expect < actual && + test_cmp expect actual + +' + +test_tick +cat >input < $GIT_COMMITTER_DATE +data <expect < actual && + test_cmp expect actual + +' + +test_tick +cat >input < $GIT_COMMITTER_DATE +data <expect < actual && + test_cmp expect actual + +' + +test_tick +cat >input < $GIT_COMMITTER_DATE +data <expect < actual && + test_cmp expect actual + +' + +test_tick +cat >input < $GIT_COMMITTER_DATE +data <expect < actual && + test_cmp expect actual + +' + +test_tick +cat >input < $GIT_COMMITTER_DATE +data <expect < actual && + test_cmp expect actual + +' + +# Write fast-import commands to create the given number of commits +fast_import_commits () { + my_ref=$1 + my_num_commits=$2 + my_append_to_file=$3 + my_i=0 + while test $my_i -lt $my_num_commits + do + my_i=$(($my_i + 1)) + test_tick + cat >>"$my_append_to_file" < $GIT_COMMITTER_DATE +data <>"$my_append_to_file" < $GIT_COMMITTER_DATE +data <>"$my_append_to_file" <>expect < actual && + test_cmp expect actual + +' + +test_expect_success 'verify that lots of notes trigger a fanout scheme' ' + + # None of the entries in the top-level notes tree should be a full SHA1 + git cat-file -p refs/notes/many_notes: | + while read mode type sha1 path + do + path_len=$(expr length "$path") && + if test $path_len -ge 40 + then + return 1 + fi + done + +' + +commit1=$(git rev-parse "refs/heads/many_commits") +commit2=$(git rev-parse "$commit1^") +commit3=$(git rev-parse "$commit2^") +commit4=$(git rev-parse "$commit3^") + +test_tick +cat >input < $GIT_COMMITTER_DATE +data <>expect <>expect < actual && + test_cmp expect actual + +' + +test_expect_success 'verify that removing notes trigger fanout consolidation' ' + + # All entries in the top-level notes tree should be a full SHA1 + git cat-file -p refs/notes/many_notes: | + while read mode type sha1 path + do + path_len=$(expr length "$path") && + if test $path_len -ne 40 + then + return 1 + fi + done + +' + +rm input expect +num_notes_refs=10 +num_commits=16 +some_commits=8 +# Create commits +fast_import_commits "refs/heads/more_commits" $num_commits input +# Create one note per above commit per notes ref +i=0 +while test $i -lt $num_notes_refs +do + i=$(($i + 1)) + fast_import_notes "refs/notes/more_notes_$i" $num_commits input +done +# Trigger branch reloading in git-fast-import by repeating the note creation +i=0 +while test $i -lt $num_notes_refs +do + i=$(($i + 1)) + fast_import_notes "refs/notes/more_notes_$i" $some_commits input " (2)" +done +# Finally create the expected output from the notes in refs/notes/more_notes_1 +i=$num_commits +while test $i -gt 0 +do + note_data="note for commit #$i" + if test $i -le $some_commits + then + note_data="$note_data (2)" + fi + cat >>expect < actual && + test_cmp expect actual + +' + +test_done -- 1.6.4.304.g1365c.dirty