diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-08-17 17:36:22 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-08-17 17:36:22 -0700 |
commit | 324b6b1678a3c1c6179f53fccf4e5fe2cef43240 (patch) | |
tree | d59ceeace1abf83b562bd8bac5285130f86c9593 /t | |
parent | da68bf337664f6160d56153cfe4a38c49a5185f3 (diff) | |
parent | 9e8137238d1b7f558dd61c8737883e73c8368e4b (diff) | |
download | git-324b6b1678a3c1c6179f53fccf4e5fe2cef43240.tar.gz git-324b6b1678a3c1c6179f53fccf4e5fe2cef43240.tar.xz |
Merge branch 'mh/check-attr-relative'
* mh/check-attr-relative: (29 commits)
test-path-utils: Add subcommand "prefix_path"
test-path-utils: Add subcommand "absolute_path"
git-check-attr: Normalize paths
git-check-attr: Demonstrate problems with relative paths
git-check-attr: Demonstrate problems with unnormalized paths
git-check-attr: test that no output is written to stderr
Rename git_checkattr() to git_check_attr()
git-check-attr: Fix command-line handling to match docs
git-check-attr: Drive two tests using the same raw data
git-check-attr: Add an --all option to show all attributes
git-check-attr: Error out if no pathnames are specified
git-check-attr: Process command-line args more systematically
git-check-attr: Handle each error separately
git-check-attr: Extract a function error_with_usage()
git-check-attr: Introduce a new variable
git-check-attr: Extract a function output_attr()
Allow querying all attributes on a file
Remove redundant check
Remove redundant call to bootstrap_attr_stack()
Extract a function collect_all_attrs()
...
Diffstat (limited to 't')
-rwxr-xr-x | t/t0003-attributes.sh | 90 |
1 files changed, 69 insertions, 21 deletions
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index ebbc7554a..ae2f1da28 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -9,16 +9,17 @@ attr_check () { path="$1" expect="$2" - git check-attr test -- "$path" >actual && + git check-attr test -- "$path" >actual 2>err && echo "$path: test: $2" >expect && - test_cmp expect actual + test_cmp expect actual && + test_line_count = 0 err } test_expect_success 'setup' ' - mkdir -p a/b/d a/c && + mkdir -p a/b/d a/c b && ( echo "[attr]notest !test" echo "f test=f" @@ -35,10 +36,42 @@ test_expect_success 'setup' ' echo "h test=a/b/h" && echo "d/* test=a/b/d/*" echo "d/yes notest" - ) >a/b/.gitattributes + ) >a/b/.gitattributes && ( echo "global test=global" - ) >"$HOME"/global-gitattributes + ) >"$HOME"/global-gitattributes && + cat <<EOF >expect-all +f: test: f +a/f: test: f +a/c/f: test: f +a/g: test: a/g +a/b/g: test: a/b/g +b/g: test: unspecified +a/b/h: test: a/b/h +a/b/d/g: test: a/b/d/* +onoff: test: unset +offon: test: set +no: notest: set +no: test: unspecified +a/b/d/no: notest: set +a/b/d/no: test: a/b/d/* +a/b/d/yes: notest: set +a/b/d/yes: test: unspecified +EOF + +' + +test_expect_success 'command line checks' ' + + test_must_fail git check-attr && + test_must_fail git check-attr -- && + test_must_fail git check-attr test && + test_must_fail git check-attr test -- && + test_must_fail git check-attr -- f && + echo "f" | test_must_fail git check-attr --stdin && + echo "f" | test_must_fail git check-attr --stdin -- f && + echo "f" | test_must_fail git check-attr --stdin test -- f && + test_must_fail git check-attr "" -- f ' @@ -60,6 +93,28 @@ test_expect_success 'attribute test' ' ' +test_expect_success 'unnormalized paths' ' + + attr_check ./f f && + attr_check ./a/g a/g && + attr_check a/./g a/g && + attr_check a/c/../b/g a/b/g + +' + +test_expect_success 'relative paths' ' + + (cd a && attr_check ../f f) && + (cd a && attr_check f f) && + (cd a && attr_check i a/i) && + (cd a && attr_check g a/g) && + (cd a && attr_check b/g a/b/g) && + (cd b && attr_check ../a/f f) && + (cd b && attr_check ../a/g a/g) && + (cd b && attr_check ../a/b/g a/b/g) + +' + test_expect_success 'core.attributesfile' ' attr_check global unspecified && git config core.attributesfile "$HOME/global-gitattributes" && @@ -72,26 +127,19 @@ test_expect_success 'core.attributesfile' ' test_expect_success 'attribute test: read paths from stdin' ' - cat <<EOF > expect && -f: test: f -a/f: test: f -a/c/f: test: f -a/g: test: a/g -a/b/g: test: a/b/g -b/g: test: unspecified -a/b/h: test: a/b/h -a/b/d/g: test: a/b/d/* -onoff: test: unset -offon: test: set -no: test: unspecified -a/b/d/no: test: a/b/d/* -a/b/d/yes: test: unspecified -EOF - + grep -v notest < expect-all > expect && sed -e "s/:.*//" < expect | git check-attr --stdin test > actual && test_cmp expect actual ' +test_expect_success 'attribute test: --all option' ' + + grep -v unspecified < expect-all | sort > expect && + sed -e "s/:.*//" < expect-all | uniq | + git check-attr --stdin --all | sort > actual && + test_cmp expect actual +' + test_expect_success 'root subdir attribute test' ' attr_check a/i a/i && |