From 2179b6727efb5493f9871f8903883d6359486208 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 25 Nov 2013 12:53:54 -0800 Subject: mark perl test scripts executable These scripts are not run directly as part of a normal build, so no one noticed that they did not have the +x bit. Mark them executable to make it more obvious that they can be run directly (when debugging, for example). Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/Git-SVN/00compile.t | 0 t/Git-SVN/Utils/add_path_to_url.t | 0 t/Git-SVN/Utils/can_compress.t | 0 t/Git-SVN/Utils/canonicalize_url.t | 0 t/Git-SVN/Utils/collapse_dotdot.t | 0 t/Git-SVN/Utils/fatal.t | 0 t/Git-SVN/Utils/join_paths.t | 0 t/t0202/test.pl | 0 t/t9150/make-svk-dump | 0 t/t9151/make-svnmerge-dump | 0 10 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 t/Git-SVN/00compile.t mode change 100644 => 100755 t/Git-SVN/Utils/add_path_to_url.t mode change 100644 => 100755 t/Git-SVN/Utils/can_compress.t mode change 100644 => 100755 t/Git-SVN/Utils/canonicalize_url.t mode change 100644 => 100755 t/Git-SVN/Utils/collapse_dotdot.t mode change 100644 => 100755 t/Git-SVN/Utils/fatal.t mode change 100644 => 100755 t/Git-SVN/Utils/join_paths.t mode change 100644 => 100755 t/t0202/test.pl mode change 100644 => 100755 t/t9150/make-svk-dump mode change 100644 => 100755 t/t9151/make-svnmerge-dump (limited to 't') diff --git a/t/Git-SVN/00compile.t b/t/Git-SVN/00compile.t old mode 100644 new mode 100755 diff --git a/t/Git-SVN/Utils/add_path_to_url.t b/t/Git-SVN/Utils/add_path_to_url.t old mode 100644 new mode 100755 diff --git a/t/Git-SVN/Utils/can_compress.t b/t/Git-SVN/Utils/can_compress.t old mode 100644 new mode 100755 diff --git a/t/Git-SVN/Utils/canonicalize_url.t b/t/Git-SVN/Utils/canonicalize_url.t old mode 100644 new mode 100755 diff --git a/t/Git-SVN/Utils/collapse_dotdot.t b/t/Git-SVN/Utils/collapse_dotdot.t old mode 100644 new mode 100755 diff --git a/t/Git-SVN/Utils/fatal.t b/t/Git-SVN/Utils/fatal.t old mode 100644 new mode 100755 diff --git a/t/Git-SVN/Utils/join_paths.t b/t/Git-SVN/Utils/join_paths.t old mode 100644 new mode 100755 diff --git a/t/t0202/test.pl b/t/t0202/test.pl old mode 100644 new mode 100755 diff --git a/t/t9150/make-svk-dump b/t/t9150/make-svk-dump old mode 100644 new mode 100755 diff --git a/t/t9151/make-svnmerge-dump b/t/t9151/make-svnmerge-dump old mode 100644 new mode 100755 -- cgit v1.2.1 From b018c73526ca9d941c64d6a41d9c24968de38c2b Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 25 Nov 2013 13:02:16 -0800 Subject: test: make FILEMODE a lazy prereq This way, test authors don't need to remember to source lib-prereq-FILEMODE.sh before using the FILEMODE prereq to guard tests that rely on the executable bit being honored when checking out files. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/lib-prereq-FILEMODE.sh | 11 ----------- t/t3701-add-interactive.sh | 1 - t/t4102-apply-rename.sh | 1 - t/t4120-apply-popt.sh | 1 - t/t4129-apply-samemode.sh | 1 - t/t6031-merge-recursive.sh | 1 - t/t9200-git-cvsexportcommit.sh | 1 - t/test-lib.sh | 4 ++++ 8 files changed, 4 insertions(+), 17 deletions(-) delete mode 100644 t/lib-prereq-FILEMODE.sh (limited to 't') diff --git a/t/lib-prereq-FILEMODE.sh b/t/lib-prereq-FILEMODE.sh deleted file mode 100644 index bce5a4c8b..000000000 --- a/t/lib-prereq-FILEMODE.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2010 Ævar Arnfjörð Bjarmason -# - -if test "$(git config --bool core.filemode)" = false -then - say 'filemode disabled on the filesystem' -else - test_set_prereq FILEMODE -fi diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 9dc91d09d..24ddd8a70 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -2,7 +2,6 @@ test_description='add -i basic tests' . ./test-lib.sh -. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh if ! test_have_prereq PERL then diff --git a/t/t4102-apply-rename.sh b/t/t4102-apply-rename.sh index e3ea3d511..49e2d6c34 100755 --- a/t/t4102-apply-rename.sh +++ b/t/t4102-apply-rename.sh @@ -7,7 +7,6 @@ test_description='git apply handling copy/rename patch. ' . ./test-lib.sh -. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh # setup diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh index c5fecdfed..497b62868 100755 --- a/t/t4120-apply-popt.sh +++ b/t/t4120-apply-popt.sh @@ -6,7 +6,6 @@ test_description='git apply -p handling.' . ./test-lib.sh -. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh test_expect_success setup ' mkdir sub && diff --git a/t/t4129-apply-samemode.sh b/t/t4129-apply-samemode.sh index 0d36ebdc8..c268298ea 100755 --- a/t/t4129-apply-samemode.sh +++ b/t/t4129-apply-samemode.sh @@ -3,7 +3,6 @@ test_description='applying patch with mode bits' . ./test-lib.sh -. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh test_expect_success setup ' echo original >file && diff --git a/t/t6031-merge-recursive.sh b/t/t6031-merge-recursive.sh index 1cd649e24..a953f1b55 100755 --- a/t/t6031-merge-recursive.sh +++ b/t/t6031-merge-recursive.sh @@ -2,7 +2,6 @@ test_description='merge-recursive: handle file mode' . ./test-lib.sh -. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh test_expect_success 'mode change in one branch: keep changed version' ' : >file1 && diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh index 3fb336890..812c9cd46 100755 --- a/t/t9200-git-cvsexportcommit.sh +++ b/t/t9200-git-cvsexportcommit.sh @@ -5,7 +5,6 @@ test_description='Test export of commits to CVS' . ./test-lib.sh -. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh if ! test_have_prereq PERL; then skip_all='skipping git cvsexportcommit tests, perl not available' diff --git a/t/test-lib.sh b/t/test-lib.sh index b25249ec4..596815704 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -830,6 +830,10 @@ test_lazy_prereq SYMLINKS ' ln -s x y && test -h y ' +test_lazy_prereq FILEMODE ' + test "$(git config --bool core.filemode)" = true +' + test_lazy_prereq CASE_INSENSITIVE_FS ' echo good >CamelCase && echo bad >camelcase && -- cgit v1.2.1 From c74c72034f061d1d9d5b8b1fba20ce0138d423b4 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 25 Nov 2013 13:03:06 -0800 Subject: test: replace shebangs with descriptions in shell libraries A #! line in these files is misleading, since these scriptlets are meant to be sourced with '.' (using whatever shell sources them) instead of run directly using the interpreter named on the #! line. Removing the #! line shouldn't hurt syntax highlighting since these files have filenames ending with '.sh'. For documentation, add a brief description of how the files are meant to be used in place of the shebang line. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/gitweb-lib.sh | 3 ++- t/lib-bash.sh | 7 +++---- t/lib-cvs.sh | 2 +- t/lib-diff-alternative.sh | 3 ++- t/lib-gettext.sh | 3 ++- t/lib-git-daemon.sh | 18 +++++++++++++++++- t/lib-httpd.sh | 29 ++++++++++++++++++++++++++++- t/lib-pack.sh | 2 -- t/lib-pager.sh | 2 +- t/lib-read-tree.sh | 2 -- t/lib-rebase.sh | 2 +- t/lib-terminal.sh | 2 +- t/perf/perf-lib.sh | 4 +++- t/test-lib-functions.sh | 3 ++- t/test-lib.sh | 2 +- 15 files changed, 64 insertions(+), 20 deletions(-) (limited to 't') diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh index 8cf909a6c..d5dab5a94 100644 --- a/t/gitweb-lib.sh +++ b/t/gitweb-lib.sh @@ -1,4 +1,5 @@ -#!/bin/sh +# Initialization and helpers for Gitweb tests, which source this +# shell library instead of test-lib.sh. # # Copyright (c) 2007 Jakub Narebski # diff --git a/t/lib-bash.sh b/t/lib-bash.sh index 11397f747..2be955faf 100644 --- a/t/lib-bash.sh +++ b/t/lib-bash.sh @@ -1,7 +1,6 @@ -#!/bin/sh -# -# Ensures that tests are run under Bash; primarily intended for running tests -# of the completion script. +# Shell library sourced instead of ./test-lib.sh by tests that need +# to run under Bash; primarily intended for tests of the completion +# script. if test -n "$BASH" && test -z "$POSIXLY_CORRECT"; then # we are in full-on bash mode diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh index 44263ade2..507671891 100644 --- a/t/lib-cvs.sh +++ b/t/lib-cvs.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# Shell library sourced instead of ./test-lib.sh by cvsimport tests. . ./test-lib.sh diff --git a/t/lib-diff-alternative.sh b/t/lib-diff-alternative.sh index 75ffd9174..8b4dbf22d 100644 --- a/t/lib-diff-alternative.sh +++ b/t/lib-diff-alternative.sh @@ -1,4 +1,5 @@ -#!/bin/sh +# Helpers shared by the test scripts for diff algorithms (patience, +# histogram, etc). test_diff_frobnitz() { cat >file1 <<\EOF diff --git a/t/lib-gettext.sh b/t/lib-gettext.sh index ae8883a07..eec757f10 100644 --- a/t/lib-gettext.sh +++ b/t/lib-gettext.sh @@ -1,4 +1,5 @@ -#!/bin/sh +# Initialization and Icelandic locale for basic git i18n tests, +# which source this scriptlet instead of ./test-lib.sh. # # Copyright (c) 2010 Ævar Arnfjörð Bjarmason # diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh index 87f0ad8f4..394b06b32 100644 --- a/t/lib-git-daemon.sh +++ b/t/lib-git-daemon.sh @@ -1,4 +1,20 @@ -#!/bin/sh +# Shell library to run git-daemon in tests. Ends the test early if +# GIT_TEST_GIT_DAEMON is not set. +# +# Usage: +# +# . ./test-lib.sh +# . "$TEST_DIRECTORY"/lib-git-daemon.sh +# start_git_daemon +# +# test_expect_success '...' ' +# ... +# ' +# +# test_expect_success ... +# +# stop_git_daemon +# test_done if test -z "$GIT_TEST_GIT_DAEMON" then diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index ad8f1ef71..c4707843c 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -1,4 +1,31 @@ -#!/bin/sh +# Shell library to run an HTTP server for use in tests. +# Ends the test early if httpd tests should not be run, +# for example because the user has not enabled them. +# +# Usage: +# +# . ./test-lib.sh +# . "$TEST_DIRECTORY"/lib-httpd.sh +# start_httpd +# +# test_expect_success '...' ' +# ... +# ' +# +# test_expect_success ... +# +# stop_httpd +# test_done +# +# Can be configured using the following variables. +# +# GIT_TEST_HTTPD enable HTTPD tests +# LIB_HTTPD_PATH web server path +# LIB_HTTPD_MODULE_PATH web server modules path +# LIB_HTTPD_PORT listening port +# LIB_HTTPD_DAV enable DAV +# LIB_HTTPD_SVN enable SVN +# LIB_HTTPD_SSL enable SSL # # Copyright (c) 2008 Clemens Buchacher # diff --git a/t/lib-pack.sh b/t/lib-pack.sh index b96e1254d..750984657 100644 --- a/t/lib-pack.sh +++ b/t/lib-pack.sh @@ -1,5 +1,3 @@ -#!/bin/sh -# # Support routines for hand-crafting weird or malicious packs. # # You can make a complete pack like: diff --git a/t/lib-pager.sh b/t/lib-pager.sh index ba03eab14..3aa7a3ffd 100644 --- a/t/lib-pager.sh +++ b/t/lib-pager.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# Helpers for tests of git's choice of pager. test_expect_success 'determine default pager' ' test_might_fail git config --unset core.pager && diff --git a/t/lib-read-tree.sh b/t/lib-read-tree.sh index abc2c6f57..6442ae337 100644 --- a/t/lib-read-tree.sh +++ b/t/lib-read-tree.sh @@ -1,5 +1,3 @@ -#!/bin/sh -# # Helper functions to check if read-tree would succeed/fail as expected with # and without the dry-run option. They also test that the dry-run does not # write the index and that together with -u it doesn't touch the work tree. diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 8ff87fb3f..6bd252212 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# Helper functions used by interactive rebase tests. # After setting the fake editor with this function, you can # diff --git a/t/lib-terminal.sh b/t/lib-terminal.sh index 737df289a..9a2dca506 100644 --- a/t/lib-terminal.sh +++ b/t/lib-terminal.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# Helpers for terminal output tests. test_expect_success PERL 'set up terminal for tests' ' # Reading from the pty master seems to get stuck _sometimes_ diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh index f4eecaa17..a8c957429 100644 --- a/t/perf/perf-lib.sh +++ b/t/perf/perf-lib.sh @@ -1,4 +1,6 @@ -#!/bin/sh +# Performance testing framework. Each perf script starts much like +# a normal test script, except it sources this library instead of +# test-lib.sh. See t/perf/README for documentation. # # Copyright (c) 2011 Thomas Rast # diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 2f79146e6..aeae3ca76 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1,4 +1,5 @@ -#!/bin/sh +# Library of functions shared by all tests scripts, included by +# test-lib.sh. # # Copyright (c) 2005 Junio C Hamano # diff --git a/t/test-lib.sh b/t/test-lib.sh index 596815704..c306bd066 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# Test framework for git. See t/README for usage. # # Copyright (c) 2005 Junio C Hamano # -- cgit v1.2.1 From 11d62145b904b81013d1ad558d68a74e22e81a91 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 25 Nov 2013 13:03:52 -0800 Subject: remove #!interpreter line from shell libraries In a shell snippet meant to be sourced by other shell scripts, an opening #! line does more harm than good. The harm: - When the shell library is sourced, the interpreter and options from the #! line are not used. Specifying a particular shell can confuse the reader into thinking it is safe for the shell library to rely on idiosyncrasies of that shell. - Using #! instead of a plain comment drops a helpful visual clue that this is a shell library and not a self-contained script. - Tools such as lintian can use a #! line to tell when an installation script has failed by forgetting to set a script executable. This check does not work if shell libraries also start with a #! line. The good: - Text editors notice the #! line and use it for syntax highlighting if you try to edit the installed scripts (without ".sh" suffix) in place. The use of the #! for file type detection is not needed because Git's shell libraries are meant to be edited in source form (with ".sh" suffix). Replace the opening #! lines with comments. This involves tweaking the test harness's valgrind support to find shell libraries by looking for "# " in the first line instead of "#!" (see v1.7.6-rc3~7, 2011-06-17). Suggested by Russ Allbery through lintian. Thanks to Jeff King and Clemens Buchacher for further analysis. Tested by searching for non-executable scripts with #! line: find . -name .git -prune -o -type f -not -executable | while read file do read line <"$file" case $line in '#!'*) echo "$file" ;; esac done The only remaining scripts found are templates for shell scripts (unimplemented.sh, wrap-for-bin.sh) and sample input used in tests (t/t4034/perl/{pre,post}). Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/test-lib.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 't') diff --git a/t/test-lib.sh b/t/test-lib.sh index c306bd066..c3e07b9e1 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -573,11 +573,9 @@ then make_valgrind_symlink () { # handle only executables, unless they are shell libraries that - # need to be in the exec-path. We will just use "#!" as a - # guess for a shell-script, since we have no idea what the user - # may have configured as the shell path. + # need to be in the exec-path. test -x "$1" || - test "#!" = "$(head -c 2 <"$1")" || + test "# " = "$(head -c 2 <"$1")" || return; base=$(basename "$1") -- cgit v1.2.1