Download raw body.
tog: basic diff regress
On 23-04-15 02:05AM, Mark Jamsek wrote: > On 23-04-15 02:02AM, Mark Jamsek wrote: > > On 23-04-15 02:00AM, Mark Jamsek wrote: > > > The below diff adds two basic tog diff tests: one for contiguous (direct > > > parent/child 'tog diff parent child') commits; and another for arbitrary > > > commits. > > > > Ignore previous, below fixes some 'log' copypasta. > > Ah! Ignore both for the time being :) This fixes the silly error for the moment so you can at least run the basic diff tests (and review as they won't functionally change). But I'm not entirely happy with how we set the script envvar as I want that to be really simple so I will revisit that tomorrow after some zzz. diff /home/mark/src/got commit - b568caa8aa856a6b8c4c435003250c6dd80b19a3 path + /home/mark/src/got blob - 01409b433f1bc9d3bbbc19b1428c29ddf72802e1 file + regress/tog/Makefile --- regress/tog/Makefile +++ regress/tog/Makefile @@ -1,4 +1,4 @@ -REGRESS_TARGETS=log +REGRESS_TARGETS=log diff NOOBJ=Yes GOT_TEST_ROOT=/tmp @@ -6,4 +6,7 @@ log: log: ./log.sh -q -r "$(GOT_TEST_ROOT)" +diff: + ./diff.sh -q -r "$(GOT_TEST_ROOT)" + .include <bsd.regress.mk> blob - cba908caf919a31069c38c9bd18d8b7ea8952ba1 file + regress/tog/common.sh --- regress/tog/common.sh +++ regress/tog/common.sh @@ -88,7 +88,7 @@ test_init() testroot=`mktemp -d "$GOT_TEST_ROOT/tog-test-$testname-XXXXXXXX"` - set_test_env $testroot/log_test $testroot/view $columns $lines + set_test_env $testroot/$testname $testroot/view $columns $lines mkdir $testroot/repo git_init $testroot/repo blob - /dev/null file + regress/tog/diff.sh (mode 755) --- /dev/null +++ regress/tog/diff.sh @@ -0,0 +1,136 @@ +#!/bin/sh +# +# Copyright (c) 2023 Mark Jamsek <mark@jamsek.dev> +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +. ./common.sh + +test_diff_contiguous_commits() +{ + test_init diff_contiguous_commits + + local commit_id1=`git_show_head $testroot/repo` + local alpha_id_old=`get_blob_id $testroot/repo "" alpha` + + echo "modified alpha" > $testroot/repo/alpha + git_commit $testroot/repo -m "changed alpha" + local author_time=`git_show_author_time $testroot/repo` + local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"` + local head_id=`git_show_head $testroot/repo` + local head_id_truncated=`trim_obj_id 13 $head_id` + local alpha_id=`get_blob_id $testroot/repo "" alpha` + + cat <<EOF >$testroot/diff_contiguous_commits +SCREENDUMP +EOF + + cat <<EOF >$testroot/view.expected +[1/20] diff $commit_id1 $head_id_truncated +commit $head_id (master) +from: Flan Hacker <flan_hacker@openbsd.org> +date: $date + +changed alpha + +M alpha | 1+ 1- + +1 file changed, 1 insertion(+), 1 deletion(-) + +commit - $commit_id1 +commit + $head_id +blob - $alpha_id_old +blob + $alpha_id +--- alpha ++++ alpha +@@ -1 +1 @@ +-alpha ++modified alpha + + + +(END) +EOF + + cd $testroot/repo && tog diff $commit_id1 $head_id + cmp -s $testroot/view.expected $testroot/view + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/view.expected $testroot/view + test_done "$testroot" "$ret" + return 1 + fi + + test_done "$testroot" "$ret" +} + +test_diff_arbitrary_commits() +{ + test_init diff_arbitrary_commits 80 18 + + local commit_id1=`git_show_head $testroot/repo` + local alpha_id_old=`get_blob_id $testroot/repo "" alpha` + + echo "modified alpha" > $testroot/repo/alpha + git_commit $testroot/repo -m "changed alpha" + local commit_id2=`git_show_head $testroot/repo` + + echo "modified alpha again" > $testroot/repo/alpha + echo "new file" > $testroot/repo/new + (cd $testroot/repo && git add new) + git_commit $testroot/repo -m "new file" + local head_id=`git_show_head $testroot/repo` + local head_id_truncated=`trim_obj_id 13 $head_id` + local alpha_id=`get_blob_id $testroot/repo "" alpha` + local new_id=`get_blob_id $testroot/repo "" new` + + cat <<EOF >$testroot/diff_arbitrary_commits +SCREENDUMP +EOF + + cat <<EOF >$testroot/view.expected +[1/16] diff $commit_id1 $head_id_truncated +commit - $commit_id1 +commit + $head_id +blob - $alpha_id_old +blob + $alpha_id +--- alpha ++++ alpha +@@ -1 +1 @@ +-alpha ++modified alpha again +blob - /dev/null +blob + $new_id (mode 644) +--- /dev/null ++++ new +@@ -0,0 +1 @@ ++new file + +(END) +EOF + + cd $testroot/repo && tog diff $commit_id1 $head_id + cmp -s $testroot/view.expected $testroot/view + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/view.expected $testroot/view + test_done "$testroot" "$ret" + return 1 + fi + + test_done "$testroot" "$ret" +} + +test_parseargs "$@" +run_test test_diff_contiguous_commits +run_test test_diff_arbitrary_commits blob - 17a02a06bcc9a0d2dfc44329aa56339f21148c9d file + regress/tog/log.sh --- regress/tog/log.sh +++ regress/tog/log.sh @@ -25,7 +25,7 @@ test_log_hsplit_diff() local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"` local ymd=`date -u -r $author_time +"%G-%m-%d"` - cat <<EOF >$testroot/log_test + cat <<EOF >$testroot/log_hsplit_diff KEY_ENTER open diff view of selected commit S toggle horizontal split SCREENDUMP @@ -82,7 +82,7 @@ test_log_vsplit_diff() local blobid_alpha=`get_blob_id $testroot/repo "" alpha` local blobid_beta=`get_blob_id $testroot/repo "" beta` - cat <<EOF >$testroot/log_test + cat <<EOF >$testroot/log_vsplit_diff KEY_ENTER open diff view of selected commit in vertical split SCREENDUMP EOF @@ -146,7 +146,7 @@ test_log_show_author() local commit1=`git_show_head $testroot/repo` local id1_len8=`trim_obj_id 32 $commit1` - cat <<EOF >$testroot/log_test + cat <<EOF >$testroot/log_show_author @ toggle show author SCREENDUMP EOF @@ -186,7 +186,7 @@ test_log_scroll_right() local commit1=`git_show_head $testroot/repo` - cat <<EOF >$testroot/log_test + cat <<EOF >$testroot/log_scroll_right l scroll right l scroll right SCREENDUMP @@ -219,7 +219,7 @@ test_log_hsplit_ref() local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"` local ymd=`date -u -r $author_time +"%G-%m-%d"` - cat <<EOF >$testroot/log_test + cat <<EOF >$testroot/log_hsplit_ref R open ref view S toggle horizontal split - reduce size of ref view split @@ -260,7 +260,7 @@ test_log_hsplit_tree() local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"` local ymd=`date -u -r $author_time +"%G-%m-%d"` - cat <<EOF >$testroot/log_test + cat <<EOF >$testroot/log_hsplit_tree T open tree view S toggle horizontal split j move selection cursor down one entry to "beta" @@ -306,7 +306,7 @@ test_log_logmsg_widechar() local commit1=`git_show_parent_commit $testroot/repo` local blobid=`get_blob_id $testroot/repo "" $(widechar_filename)` - cat <<EOF >$testroot/log_test + cat <<EOF >$testroot/log_logmsg_widechar KEY_ENTER open selected commit in diff view F toggle fullscreen SCREENDUMP -- Mark Jamsek <fnc.bsdbox.org|got.bsdbox.org> GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68
tog: basic diff regress