#!/bin/bash # Do all the work in /tmp $ cd /tmp # Testing presence of Mercurial $ hg --version re: Mercurial Distributed SCM \(version [\d.]+\) (see http://mercurial.selenic.com for more information) re: Copyright \(C\) [\d-]+ Matt Mackall and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # Creating a repository $ mkdir foo $ cd foo $ pwd /tmp/foo $ hg init $ echo "this is a file" > content $ cat content this is a file $ hg add content $ hg st A content $ hg commit -m "created repo and added a file" # Checking that everything looks good $ hg log re: changeset: 0:[a-f0-9]{12} tag: tip user: Fabrice Gabolde re: date: .* summary: created repo and added a file #### # cd /tmp # hg --version ok 1 - regex match of 'Mercurial Distributed SCM \(version [\d.]+\)' ok 2 - literal match of '(see http://mercurial.selenic.com for more information)' ok 3 - literal match of '' ok 4 - regex match of 'Copyright \(C\) [\d-]+ Matt Mackall and others' ok 5 - literal match of 'This is free software; see the source for copying conditions. There is NO' ok 6 - literal match of 'warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.' # mkdir foo # cd foo # pwd not ok 7 - literal match of '/tmp/foo' # Failed test 'literal match of '/tmp/foo'' # at lib/Lembas.pm line 87. # got: '/home/fgabolde/work/Lembas' # expected: '/tmp/foo' # hg init # echo "this is a file" > content # cat content # STDERR: cat: content # STDERR: : No such file or directory #### my ($input, $output, $errput); my $subprocess = start([ '/bin/bash' ], '<', \$input, '1>pty>', \$output, '2>', \$errput); # later, for each $command { shell => 'pwd', 'outputs' => [ '/tmp/foo' ] } diag $command->{shell}; $input = $command->{shell} . "\n"; foreach my $expected_output (@{$command->{outputs}}) { while ($output !~ /\n/) { if ($errput) { diag 'STDERR: '.$errput; $errput = ''; } $subprocess->pump; } # munge $expected_output and compare stuff }