Fix diff output for failed tests on windows, which typically doesn't have a 'diff...
authorHappy-melon <happy-melon@users.mediawiki.org>
Sun, 16 Jan 2011 23:43:15 +0000 (23:43 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Sun, 16 Jan 2011 23:43:15 +0000 (23:43 +0000)
tests/parser/parserTest.inc

index 84f1d52..faca6c7 100644 (file)
@@ -1063,7 +1063,9 @@ class ParserTest {
         * @return String
         */
        protected function quickDiff( $input, $output, $inFileTail = 'expected', $outFileTail = 'actual' ) {
-               $prefix = wfTempDir() . "/mwParser-" . mt_rand();
+               # Windows, or at least the fc utility, is retarded
+               $slash = wfIsWindows() ? '\\' : '/';
+               $prefix = wfTempDir() . "{$slash}mwParser-" . mt_rand();
 
                $infile = "$prefix-$inFileTail";
                $this->dumpToFile( $input, $infile );
@@ -1071,7 +1073,12 @@ class ParserTest {
                $outfile = "$prefix-$outFileTail";
                $this->dumpToFile( $output, $outfile );
 
-               $diff = `diff -au $infile $outfile`;
+               $shellInfile = wfEscapeShellArg($infile);
+               $shellOutfile = wfEscapeShellArg($outfile);
+
+               $diff = wfIsWindows()
+                       ? `fc $shellInfile $shellOutfile`
+                       : `diff -au $shellInfile $shellOutfile`;
                unlink( $infile );
                unlink( $outfile );