*** empty log message ***
[coreutils.git] / tests / ls-2 / quoting
blob0eb53f5a49553776b70f7683d75f973c151e36d3
1 #!/usr/bin/perl -w
2 require 5.003;
3 use strict;
5 my $program_name;
6 ($program_name = $0) =~ s|.*/||;
8 # Make sure the tools use the expected locale.
9 $ENV{LANGUAGE} = 'C';
10 $ENV{LC_ALL} = 'C';
11 $ENV{LANG} = 'C';
13 # A file spec: a scalar or a reference to a single-keyed hash
14 # ================
15 # 'contents' contents only (file name is derived from test name)
16 # {filename => 'contents'} filename and contents
17 # {filename => undef} filename only -- $(srcdir)/filename must exist
18 # (FIXME: note to self: get $srcdir from ENV)
20 # FIXME: If there is more than one input file, the you can't specify REDIRECT.
21 # PIPE is still ok.
23 # I/O spec: a hash ref with the following properties
24 # ================
25 # - one key/value pair
26 # - the key must be one of these strings: IN, OUT, ERR, EXIT
27 # - the value must be a file spec
28 # {OUT => 'data'} put data in a temp file and compare it to stdout from cmd
29 # {OUT => {'filename'=>undef}} compare contents of existing filename to
30 # stdout from cmd
31 # Ditto for `ERR', but compare with stderr
32 # {EXIT => N} expect exit status of cmd to be N
34 # There may be many input file specs. File names from the input specs
35 # are concatenated in order on the command line.
36 # There may be at most one of the OUT-, ERR-, and EXIT-keyed specs.
37 # If the OUT-(or ERR)-keyed hash ref is omitted, then expect no output
38 # on stdout (or stderr).
39 # If the EXIT-keyed one is omitted, then expect the exit status to be zero.
41 my $q_bell = {IN => {"q\a" => ''}};
42 my @Tests =
44 # test-name options input expected-output
46 ['q-', $q_bell, {OUT => "q\a\n"}],
47 ['q-N', '-N', $q_bell, {OUT => "q\a\n"}],
48 ['q-q', '-q', $q_bell, {OUT => "q?\n"}],
49 ['q-Q', '-Q', $q_bell, {OUT => "\"q\\a\"\n"}],
51 ['q-lit-q', '--quoting=literal -q', $q_bell, {OUT => "q?\n"}],
52 ['q-qs-lit', '--quoting=literal', $q_bell, {OUT => "q\a\n"}],
53 ['q-qs-sh', '--quoting=shell', $q_bell, {OUT => "q\a\n"}],
54 ['q-qs-sh-a', '--quoting=shell-always', $q_bell, {OUT => "'q\a'\n"}],
55 ['q-qs-c', '--quoting=c', $q_bell, {OUT => "\"q\\a\"\n"}],
56 ['q-qs-esc', '--quoting=escape', $q_bell, {OUT => "q\\a\n"}],
59 my $save_temps = 0;
60 my $verbose = $ENV{VERBOSE};
62 my $prog = $ENV{LS} || 'ls';
63 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
64 exit $fail;