test: add test_write_lines helper
API and implementation as suggested by Junio. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael S. Tsirkin committed
Apr 27, 2014 at 21:15 UTC
ac9afcc31cd1f7c00c2747132e5f512173613fd9
2 files changed
+27
t/README
+22
@@ -596,6 +596,28 @@ library for your script to use.
596
...
597
'
598
599
+ - test_write_lines <text>
600
+
601
+ Split <text> to white-space separated words and write it out on standard
602
+ output, one word per line.
603
+ Useful to prepare multi-line files in a compact form.
604
+
605
+ Example:
606
+
607
+ test_write_lines "a b c d e f g" >foo
608
+
609
+ Is a more compact equivalent of:
610
+ cat >foo <<-EOF
611
+ a
612
+ b
613
+ c
614
+ d
615
+ e
616
+ f
617
+ g
618
+ EOF
619
+
620
+
621
- test_pause
622
623
This command is useful for writing and debugging tests and must be
t/test-lib-functions.sh
+5
@@ -712,6 +712,11 @@ test_ln_s_add () {
712
fi
713
}
714
715
+# This function writes out its parameters, one per line
716
+test_write_lines () {
717
+ printf "%s\n" "$@"
718
+}
719
+
720
perl () {
721
command "$PERL_PATH" "$@"
722
}