aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-04-23 14:28:09 +0300
committerMichael S. Tsirkin <mst@redhat.com>2014-05-18 23:39:34 +0300
commite143e65e69310b7d8c0aaad1ba7cbfccae0f2fcc (patch)
treeb1c78dc11d98366094fb364253e0b6c9d73e0a3a
parent2f0364bba8df720c078be96d42bdd1f4bd4009e1 (diff)
downloadgit-e143e65e69310b7d8c0aaad1ba7cbfccae0f2fcc.tar.gz
test: add test_write_lines helper
API and implementation as suggested by Junio. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--t/README22
-rw-r--r--t/test-lib-functions.sh5
2 files changed, 27 insertions, 0 deletions
diff --git a/t/README b/t/README
index caeeb9dedc..2d6232fbd3 100644
--- a/t/README
+++ b/t/README
@@ -596,6 +596,28 @@ library for your script to use.
...
'
+ - test_write_lines <text>
+
+ Split <text> to white-space separated words and write it out on standard
+ output, one word per line.
+ Useful to prepare multi-line files in a compact form.
+
+ Example:
+
+ test_write_lines "a b c d e f g" >foo
+
+ Is a more compact equivalent of:
+ cat >foo <<-EOF
+ a
+ b
+ c
+ d
+ e
+ f
+ g
+ EOF
+
+
- test_pause
This command is useful for writing and debugging tests and must be
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 158e10a67e..f5815350d3 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -717,6 +717,11 @@ test_ln_s_add () {
fi
}
+# This function writes out its parameters, one per line
+test_write_lines () {
+ printf "%s\n" "$@"
+}
+
perl () {
command "$PERL_PATH" "$@"
}