From c808f10d0886cd4f7a8e88a2edd025a091f188a5 Mon Sep 17 00:00:00 2001
From: Paul Smith <psmith@nuodb.com>
Date: Sun, 1 Jul 2018 16:13:13 -0400
Subject: [PATCH] Update regression tests for Windows.

* tests/scripts/features/jobserver: Windows doesn't use pipes
* tests/scripts/functions/shell: Don't test kill -2 on Windows
* tests/scripts/misc/bs-nl: Windows doesn't handle single quotes
* tests/scripts/misc/general3: Ditto.
---
 tests/scripts/features/jobserver | 22 ++++++++++++----------
 tests/scripts/functions/shell    | 22 +++++++++++-----------
 tests/scripts/misc/bs-nl         | 10 ++++++++--
 tests/scripts/misc/general3      |  5 ++++-
 tests/scripts/variables/SHELL    |  5 +++++
 5 files changed, 40 insertions(+), 24 deletions(-)

diff --git a/tests/scripts/features/jobserver b/tests/scripts/features/jobserver
index f9781bee..73d10d9f 100644
--- a/tests/scripts/features/jobserver
+++ b/tests/scripts/features/jobserver
@@ -80,25 +80,27 @@ inc.mk:
 
 unlink('inc.mk');
 
-# Test recursion when make doesn't think it exists.
+# Test recursion which is hidden from make.
 # See Savannah bug #39934
 # Or Red Hat bug https://bugzilla.redhat.com/show_bug.cgi?id=885474
+# Windows doesn't use a pipe, and doesn't close access, so this won't happen.
+if ($port_type ne 'W32') {
+    open(MAKEFILE,"> Makefile2");
+    print MAKEFILE '
+    vpath %.c ../
+    foo:
+    ';
+    close(MAKEFILE);
 
-open(MAKEFILE,"> Makefile2");
-print MAKEFILE '
-vpath %.c ../
-foo:
-';
-close(MAKEFILE);
-
-run_make_test(q!
+    run_make_test(q!
 default: ; @ #MAKEPATH# -f Makefile2
 !,
               "-j2 $np",
 "#MAKE#[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
 #MAKE#[1]: Nothing to be done for 'foo'.");
 
-rmfiles('Makefile2');
+    rmfiles('Makefile2');
+}
 
 1;
 
diff --git a/tests/scripts/functions/shell b/tests/scripts/functions/shell
index 6e446084..bbb25dd9 100644
--- a/tests/scripts/functions/shell
+++ b/tests/scripts/functions/shell
@@ -22,17 +22,9 @@ $(shell exit 0)
 OK := $(.SHELLSTATUS)
 $(shell exit 1)
 BAD := $(.SHELLSTATUS)
-$(shell kill -2 $$$$)
-SIG := $(.SHELLSTATUS)
 all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD)
               ','','PRE= OK=0 BAD=1');
 
-run_make_test('.PHONY: all
-$(shell kill -2 $$$$)
-SIG := $(.SHELLSTATUS)
-all: ; @echo SIG=$(SIG)
-              ','','SIG=130');
-
 # Test unescaped comment characters in shells.  Savannah bug #20513
 run_make_test(q!
 FOO := $(shell echo '#')
@@ -49,10 +41,10 @@ export HI = $(shell echo hi)
 all: ; @echo $$HI
     ','','hi');
 
-# Test shell errors in recipes including offset
-# This needs to be ported to Windows, or else Windows error messages
-# need to converted to look like more normal make errors.
 if ($port_type ne 'W32') {
+    # Test shell errors in recipes including offset
+    # This needs to be ported to Windows, or else Windows error messages
+    # need to converted to look like more normal make errors.
     run_make_test('
 all:
 	@echo hi
@@ -60,6 +52,14 @@ all:
 	@echo there
 ',
                   '', "#MAKE#: ./basdfdfsed: Command not found\nhi\nthere\n");
+
+    # Test SHELLSTATUS for kill.
+    # This test could be ported to Windows, using taskkill ... ?
+    run_make_test('.PHONY: all
+$(shell kill -2 $$$$)
+SIG := $(.SHELLSTATUS)
+all: ; @echo SIG=$(SIG)
+              ','','SIG=130');
 }
 
 1;
diff --git a/tests/scripts/misc/bs-nl b/tests/scripts/misc/bs-nl
index fc323ce9..fcb64470 100644
--- a/tests/scripts/misc/bs-nl
+++ b/tests/scripts/misc/bs-nl
@@ -18,8 +18,11 @@ run_make_test("slow:;\@: no-op; echo sl\\\now\n",
 run_make_test("dquote:;\@echo \"dqu\\\note\"\n",
               '', 'dquote');
 
-run_make_test("squote:;\@echo 'squ\\\note'\n",
+# Single quotes don't behave the same in Windows
+if ($port_type ne 'W32') {
+    run_make_test("squote:;\@echo 'squ\\\note'\n",
               '', "squ\\\note");
+}
 
 # Ensure that a leading prefix character is omitted
 run_make_test("fast:;\@echo fa\\\n\tst\n",
@@ -31,8 +34,11 @@ run_make_test("slow:;\@: no-op; echo sl\\\n\tow\n",
 run_make_test("dquote:;\@echo \"dqu\\\n\tote\"\n",
               '', 'dquote');
 
-run_make_test("squote:;\@echo 'squ\\\n\tote'\n",
+# Single quotes don't behave the same in Windows
+if ($port_type ne 'W32') {
+    run_make_test("squote:;\@echo 'squ\\\n\tote'\n",
               '', "squ\\\note");
+}
 
 # Ensure that ONLY the leading prefix character is omitted
 run_make_test("fast:;\@echo fa\\\n\t  st\n",
diff --git a/tests/scripts/misc/general3 b/tests/scripts/misc/general3
index da9263a2..a4b11286 100644
--- a/tests/scripts/misc/general3
+++ b/tests/scripts/misc/general3
@@ -88,7 +88,9 @@ foo bar
 foo bar');
 
 # Test the fastpath / single quotes
-run_make_test("
+# Single quotes don't behave the same in Windows
+if ($port_type ne 'W32') {
+    run_make_test("
 all:
 	\@echo 'foo\\
 bar'
@@ -123,6 +125,7 @@ foo \
     bar
 foo \
     bar');
+}
 
 # Test the fastpath / double quotes
 run_make_test('
diff --git a/tests/scripts/variables/SHELL b/tests/scripts/variables/SHELL
index 503b96e7..4d677efd 100644
--- a/tests/scripts/variables/SHELL
+++ b/tests/scripts/variables/SHELL
@@ -5,6 +5,11 @@ $description = "Test proper handling of SHELL.";
 # If we don't have a POSIX shell available, never mind
 $is_posix_sh or return -1;
 
+# On Windows, shell names might not match
+if ($port_type eq 'W32') {
+    return -1;
+}
+
 $mshell = $sh_name;
 
 # According to POSIX, the value of SHELL in the environment has no impact on