DASM
|
00001 #!/usr/bin/perl -w 00002 ## 00003 # Test rules for the test-frontend directory: positive tests of execution 00004 # of the front end. 00005 # 00006 # *.cmd command to execute. 00007 # *.expect.output is what we expect to see. 00008 # 00009 00010 00011 ## 00012 # Run the command and check it works and matches expectations 00013 addTest('name' => 'Frontend tool', 00014 'input' => '.sh', 00015 'expect' => '.expect.output', 00016 'no-expect-skip' => 1, # Skip test if no expect file 00017 00018 'generate' => sub { 00019 my ($directory, $input) = @_; 00020 00021 my $content = readfile("$directory/$input"); 00022 00023 # Split up the command files into lines 00024 my @lines = grep { !/^\s*$/ && !/^\s*#/ } split /\n/, $content; 00025 00026 my ($rc, $output) = (1, ""); 00027 my $cmd = ""; 00028 00029 # Run every line and capture the output. 00030 for my $line (@lines) 00031 { 00032 my $moreoutput; 00033 $cmd .= "$line\n"; 00034 ($rc, $moreoutput) = capture_output($line); 00035 $output .= $moreoutput; 00036 00037 last if ($rc != 0); 00038 } 00039 00040 return ($rc, $output, $cmd); 00041 }, 00042 00043 'compare' => \&compare, 00044 ); 00045 00046 00047 ## 00048 # Run the command and check it works and matches expectations 00049 addTest('name' => 'Frontend tool failures', 00050 'input' => '.sh', 00051 'expect' => '.fail.output', 00052 'no-expect-skip' => 1, # Skip test if no expect file 00053 00054 'generate' => sub { 00055 my ($directory, $input) = @_; 00056 00057 my $content = readfile("$directory/$input"); 00058 00059 # Split up the command files into lines 00060 my @lines = grep { !/^\s*$/ && !/^\s*#/ } split /\n/, $content; 00061 00062 my ($rc, $output) = (1, ""); 00063 my $cmd = ""; 00064 00065 # Run every line and capture the output. 00066 for my $line (@lines) 00067 { 00068 my $moreoutput; 00069 $cmd .= "$line\n"; 00070 ($rc, $moreoutput) = capture_output($line); 00071 $output .= $moreoutput; 00072 00073 last if ($rc != 0); 00074 } 00075 00076 return ($rc, $output, $cmd); 00077 }, 00078 00079 'compare' => \&comparefail, 00080 ); 00081 00082 00083 # Must return true 00084 1;