]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Special-case Windows error results
authorPaul Smith <psmith@gnu.org>
Sun, 28 Nov 2021 19:17:55 +0000 (14:17 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 28 Nov 2021 19:27:10 +0000 (14:27 -0500)
* tests/scripts/features/errors: Match Windows-specific errors.
* tests/scripts/features/targetvars: Match Windows-specific errors.
* tests/scripts/misc/general4: Match Windows-specific errors.

tests/scripts/features/errors
tests/scripts/features/targetvars
tests/scripts/misc/general4

index f236d5172490c3d405287b6b6583c93f12244bba..708123c9a9fb364080e2406a7007175ec43510e4 100644 (file)
@@ -31,6 +31,18 @@ all:
 !,
               '', "hi\nthere\n#MAKE#: *** [#MAKEFILE#:5: all] Error 1", 512);
 
+# Windows error look completely different :-/
+
+sub errors_getinfo
+{
+    my ($cmd, $args) = @_;
+    if ($port_type eq 'W32') {
+        return (2, "process_begin: CreateProcess(NULL, $cmd $args, ...) failed.\nmake (e=2): The system cannot find the file specified.");
+    }
+
+    return (127, "#MAKE#: $cmd: $ERR_no_such_file");
+}
+
 # TEST #3
 # -------
 
@@ -38,35 +50,38 @@ all:
 my $unk = './foobarbazbozblat';
 unlink($unk);
 
-my $err = $ERR_no_such_file;
+my $ernum, $erstr;
 
+($ernum, $erstr) = errors_getinfo($unk, "xx yy");
 run_make_test(qq!
 one: ; -$unk xx yy
-!,
-              'one', "$unk xx yy\n#MAKE#: $unk: $err\n#MAKE#: [#MAKEFILE#:2: one] Error 127 (ignored)\n");
+!, 'one',
+              "$unk xx yy\n$erstr\n#MAKE#: [#MAKEFILE#:2: one] Error $ernum (ignored)\n");
 
 # TEST #4
 # -------
 
+($ernum, $erstr) = errors_getinfo($unk, "aa bb");
 run_make_test(qq!
 two: ; $unk aa bb
 !, 'two -i',
-              "$unk aa bb\n#MAKE#: $unk: $err\n#MAKE#: [#MAKEFILE#:2: two] Error 127 (ignored)\n");
+              "$unk aa bb\n$erstr\n#MAKE#: [#MAKEFILE#:2: two] Error $ernum (ignored)\n");
 
 # TEST #5
 # -------
 
 run_make_test(undef, 'two',
-              "$unk aa bb\n#MAKE#: $unk: $err\n#MAKE#: *** [#MAKEFILE#:2: two] Error 127\n", 512);
+              "$unk aa bb\n$erstr\n#MAKE#: *** [#MAKEFILE#:2: two] Error $ernum\n", 512);
 
 # SV #56918 : Test the unknown command as the second recipe line
 
+($ernum, $erstr) = errors_getinfo($unk, "qq rr");
 run_make_test(qq!
 three:
 \t\@echo one
 \t$unk qq rr
 !, 'three',
-              "one\n$unk qq rr\n#MAKE#: $unk: $err\n#MAKE#: *** [#MAKEFILE#:4: three] Error 127\n", 512);
+              "one\n$unk qq rr\n$erstr\n#MAKE#: *** [#MAKEFILE#:4: three] Error $ernum\n", 512);
 
 # Try failing due to non-executable file
 
index cf0424b9eb57de10405bd02fedce6f0992198dfe..5088251e4dd95d59069afd27cb1e2781aea233ac 100644 (file)
@@ -272,11 +272,20 @@ all: ; $sname >/dev/null
 
 $ENV{PATH} = "$ENV{PATH}:sd";
 
+my ($ernum, $erstr);
+if ($port_type eq 'W32') {
+    $ernum = 1;
+    $erstr = "'$sname' is not recognized as an internal or external command,\noperable program or batch file.";
+} else {
+    $ernum = 127;
+    $erstr = "#MAKE#: $sname: $ERR_no_such_file";
+}
+
 run_make_test(qq!
 all: PATH := ..
 all: ; $sname
 !,
-              '', "$sname\n#MAKE#: $sname: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:3: all] Error 127", 512);
+              '', "$sname\n$erstr\n#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512);
 
 unlink("sd/$sname");
 rmdir ('sd');
index 0077c896c7944a259fe273f805e60755a94244fa..cfd69a8987cbb3d8071ca12879504cf212102f41 100644 (file)
@@ -96,11 +96,21 @@ all: ; $sname >/dev/null
 
 $ENV{PATH} = "$ENV{PATH}:sd";
 
+my ($ernum, $erstr);
+
+if ($port_type eq 'W32') {
+    $ernum = 2;
+    $erstr = "process_begin: CreateProcess(NULL, $sname, ...) failed.\nmake (e=2): The system cannot find the file specified.";
+} else {
+    $ernum = 127;
+    $erstr = "#MAKE#: $sname: $ERR_no_such_file";
+}
+
 run_make_test(qq!
 PATH := ..
 all: ; $sname
 !,
-              '', "$sname\n#MAKE#: $sname: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:3: all] Error 127", 512);
+              '', "$sname\n$erstr\n#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512);
 
 unlink("sd/$sname");
 rmdir('sd');
@@ -110,11 +120,19 @@ rmdir('sd');
 create_file($sname, '');
 chmod 0755, $sname;
 
+if ($port_type eq 'W32') {
+    $ernum = -1;
+    $erstr = "";
+} else {
+    $ernum = 127;
+    $erstr = "#MAKE#: $sname: $ERR_no_such_file\n";
+}
+
 run_make_test(qq!
 PATH := ..
 all: ; $sname
 !,
-              '', "$sname\n#MAKE#: $sname: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:3: all] Error 127", 512);
+              '', "$sname\n$erstr#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512);
 
 unlink($sname);