From db296f755dcb98f3803a7ad1bf205d3c0b17d010 Mon Sep 17 00:00:00 2001
From: Frederich Munch <marsupial@users.noreply.github.com>
Date: Sun, 2 Oct 2016 22:47:56 -0400
Subject: [PATCH] Windows: Fix various test failures.

---
 interpreter/cling/test/ErrorRecovery/ABI.C    |  2 +-
 .../test/ErrorRecovery/SubsequentDecls.C      |  9 ++++--
 .../test/Extensions/Lookup/ControlFlow.C      |  1 +
 .../cling/test/Interfaces/compileFunc.C       |  2 +-
 .../cling/test/Interfaces/invocationFlags.C   |  2 +-
 interpreter/cling/test/Interfaces/paths.C     |  2 +-
 interpreter/cling/test/Pragmas/add_env_path.C | 22 +++++++++++++--
 interpreter/cling/test/Prompt/DontWrap.C      |  6 ++--
 interpreter/cling/test/Prompt/Regression.C    |  2 +-
 .../test/Prompt/ValuePrinter/Assignments.C    |  2 +-
 .../test/Prompt/ValuePrinter/Regression.C     | 28 ++++++++++++++++---
 interpreter/cling/test/Prompt/globalinit.C    | 15 +++++++---
 12 files changed, 73 insertions(+), 20 deletions(-)

diff --git a/interpreter/cling/test/ErrorRecovery/ABI.C b/interpreter/cling/test/ErrorRecovery/ABI.C
index 1e18bd85f12..2cf756207a4 100644
--- a/interpreter/cling/test/ErrorRecovery/ABI.C
+++ b/interpreter/cling/test/ErrorRecovery/ABI.C
@@ -6,7 +6,7 @@
 // LICENSE.TXT for details.
 //------------------------------------------------------------------------------
 
-// RUN: cat %s | %cling -nostdinc++ -nobuiltininc -Xclang -verify 2>&1 | FileCheck %s
+// RUN: cat %s | %cling %nostdincxx -nobuiltininc -Xclang -verify 2>&1 | FileCheck %s
 
 // expected-error {{'new' file not found}}
 
diff --git a/interpreter/cling/test/ErrorRecovery/SubsequentDecls.C b/interpreter/cling/test/ErrorRecovery/SubsequentDecls.C
index 78546fdf6f1..15c3bb4771c 100644
--- a/interpreter/cling/test/ErrorRecovery/SubsequentDecls.C
+++ b/interpreter/cling/test/ErrorRecovery/SubsequentDecls.C
@@ -24,7 +24,10 @@ namespace test { int y = 0; }
 .compareState "testSubsequentDecls"
 // CHECK-NOT: Differences
 
-TemplatedF((int)2) // expected-diagnostics{{C++ requires a type specifier for all declarations}} expected-diagnostics{{expected ';' after top level declarator}}
+TemplatedF((int)2)
+// CHECK: IncrementalExecutor::executeFunction: symbol '{{.*}}' unresolved while linking [cling interface function]!
+// CHECK: You are probably missing the definition of int {{.*}}TemplatedF<int>(int)
+// CHECK: Maybe you need to load the corresponding shared library?
 
 template<> int TemplatedF(int i) { return i + 100; }
 int OverloadedF(int i) { return i + 100;}
@@ -37,7 +40,9 @@ TemplatedF(__my_i)
 // CHECK: (int) 110
 
 TemplatedF((double)3.14)
-// CHECK: IncrementalExecutor::executeFunction: symbol '_Z10TemplatedFIdET_S0_' unresolved while linking
+// CHECK: IncrementalExecutor::executeFunction: symbol '{{.*}}' unresolved while linking [cling interface function]!
+// CHECK: You are probably missing the definition of double {{.*}}TemplatedF<double>(double)
+// CHECK: Maybe you need to load the corresponding shared library?
 
 // ROOT-7295
 #include <vector>
diff --git a/interpreter/cling/test/Extensions/Lookup/ControlFlow.C b/interpreter/cling/test/Extensions/Lookup/ControlFlow.C
index f8105927b1d..4ba5dce8115 100644
--- a/interpreter/cling/test/Extensions/Lookup/ControlFlow.C
+++ b/interpreter/cling/test/Extensions/Lookup/ControlFlow.C
@@ -40,6 +40,7 @@ if (h->PrintArray(a, 5)) { // runtime result type bool
   printf("\n%s\n", "Array Printed Successfully!");
 }
 // CHECK: 12345
+// CHECK: Replaced in then.
 // CHECK: Array Printed Successfully!
 
 int b, c = 1;
diff --git a/interpreter/cling/test/Interfaces/compileFunc.C b/interpreter/cling/test/Interfaces/compileFunc.C
index df0b93489e1..d10c8b866ad 100644
--- a/interpreter/cling/test/Interfaces/compileFunc.C
+++ b/interpreter/cling/test/Interfaces/compileFunc.C
@@ -50,7 +50,7 @@ void compileFunc() {
 
 
   const char* myBadFuncCode = "extern \"C\" int myBadFunc(int) { \n"
-    "return What; //expected-error@2 {{use of undeclared identifier 'What'}} \n"
+    "return NOFUZZY; //expected-error@2 {{use of undeclared identifier 'NOFUZZY'}} \n"
     "}";
 
   if (!gCling->compileFunction("myBadFunc", myBadFuncCode)) {
diff --git a/interpreter/cling/test/Interfaces/invocationFlags.C b/interpreter/cling/test/Interfaces/invocationFlags.C
index 5308ed4b253..053f1f03644 100644
--- a/interpreter/cling/test/Interfaces/invocationFlags.C
+++ b/interpreter/cling/test/Interfaces/invocationFlags.C
@@ -6,7 +6,7 @@
 // LICENSE.TXT for details.
 //------------------------------------------------------------------------------
 
-// RUN: cat %s | %built_cling -Xclang -verify | FileCheck %s
+// RUN: cat %s | %built_cling -Xclang -verify 2>&1 | FileCheck %s
 // Make sure we are correctly parsing the arguments for CIFactory::createCI
 
 #include "cling/Interpreter/InvocationOptions.h"
diff --git a/interpreter/cling/test/Interfaces/paths.C b/interpreter/cling/test/Interfaces/paths.C
index 3eed6d326ad..bf274646293 100644
--- a/interpreter/cling/test/Interfaces/paths.C
+++ b/interpreter/cling/test/Interfaces/paths.C
@@ -6,7 +6,7 @@
 // LICENSE.TXT for details.
 //------------------------------------------------------------------------------
 
-// RUN: cat %s | %cling -DTEST_PATH=\"%p/\" -Xclang -verify 2>&1 | FileCheck %s
+// RUN: cat %s | %cling -DTEST_PATH="\"%/p/\"" -Xclang -verify 2>&1 | FileCheck %s
 
 #include "cling/Interpreter/Interpreter.h"
 
diff --git a/interpreter/cling/test/Pragmas/add_env_path.C b/interpreter/cling/test/Pragmas/add_env_path.C
index 15613866960..bd75ee3aecb 100644
--- a/interpreter/cling/test/Pragmas/add_env_path.C
+++ b/interpreter/cling/test/Pragmas/add_env_path.C
@@ -7,8 +7,24 @@
 //------------------------------------------------------------------------------
 
 // RUN: mkdir -p %T/subdir && clang -DCLING_EXPORT=%dllexport -shared %S/call_lib.c -o %T/subdir/libtest%shlibext
-// RUN: %setenv ENVVAR_LIB="%T/subdir" && %setenv ENVVAR_INC="%S/subdir"
-// RUN: cat %s | %cling -I %S -Xclang -verify 2>&1 | FileCheck %s
+// RUN: cat %s | %cling -I %S -DENVVAR_LIB="\"%/T/subdir\"" -DENVVAR_INC="\"%/p/subdir\"" -Xclang -verify 2>&1 | FileCheck %s
+
+extern "C" int cling_testlibrary_function();
+
+// For gcc setenv
+#ifndef __THROW
+ #define __THROW
+#endif
+extern "C" int setenv(const char *name, const char *value, int overwrite) __THROW;
+extern "C" int _putenv_s(const char *name, const char *value);
+static void setup() {
+#ifdef _WIN32
+ #define setenv(n, v, o) _putenv_s(n,v)
+#endif
+  ::setenv("ENVVAR_INC", ENVVAR_INC, 1);
+  ::setenv("ENVVAR_LIB", ENVVAR_LIB, 1);
+}
+setup();
 
 #pragma cling add_include_path("$ENVVAR_INC")
 #include "Include_header.h"
@@ -17,6 +33,8 @@ include_test()
 
 #pragma cling add_library_path("$ENVVAR_LIB")
 #pragma cling load("libtest")
+cling_testlibrary_function()
+// CHECK: (int) 66
 
 #pragma cling add_library_path("$NONEXISTINGVARNAME")
 //expected-no-diagnostics
diff --git a/interpreter/cling/test/Prompt/DontWrap.C b/interpreter/cling/test/Prompt/DontWrap.C
index 5d9b625c4d1..fdc93f1867a 100644
--- a/interpreter/cling/test/Prompt/DontWrap.C
+++ b/interpreter/cling/test/Prompt/DontWrap.C
@@ -217,7 +217,7 @@ constexpr int cExpr() {
   return 801;
 }
 cExpr()
-// CHECK: (int) 8
+// CHECK: (int) 801
 
 int * & cIntStarRef(int*& val) {
   return val;
@@ -226,10 +226,12 @@ int * & cIntStarRef(int*& val) {
 int * RPtr = &Ref;
 int *& RefRPtr = RPtr;
 cIntStarRef(RefRPtr)
-// CHECK: (int *) 0x{{[0-9]+}}
+// CHECK: (int *) 0x{{[0-9a-f]+}}
 
 namespace Issue_113 {}
 // Keep the blank space after the using clause.
 using namespace Issue_113; 
 
+// CHECK: Nested::~Nested(80)
+
 // expected-no-diagnostics
diff --git a/interpreter/cling/test/Prompt/Regression.C b/interpreter/cling/test/Prompt/Regression.C
index e80e2ff1088..508408bfd47 100644
--- a/interpreter/cling/test/Prompt/Regression.C
+++ b/interpreter/cling/test/Prompt/Regression.C
@@ -45,7 +45,7 @@ int step = 10 // CHECK: (int) 10
 step // CHECK: (int) 10
 
 gCling->process("#ifdef __UNDEFINED__\n42\n#endif")
-//CHECK: (cling::Interpreter::CompilationResult) (cling::Interpreter::CompilationResult::kSuccess) : (unsigned int) 0
+//CHECK: (cling::Interpreter::CompilationResult) (cling::Interpreter::CompilationResult::kSuccess) : ({{(unsigned )?}}int) 0
 
 // User input variants of above:
 #ifdef NOTDEFINED
diff --git a/interpreter/cling/test/Prompt/ValuePrinter/Assignments.C b/interpreter/cling/test/Prompt/ValuePrinter/Assignments.C
index 2d5528ca537..486dd54b777 100644
--- a/interpreter/cling/test/Prompt/ValuePrinter/Assignments.C
+++ b/interpreter/cling/test/Prompt/ValuePrinter/Assignments.C
@@ -47,7 +47,7 @@ e2
 
 
 // Arrays:
-float farr[] = {0.,1.,2.,3.,4.,5.} // CHECK: (float [6]) { 0.00000f, 1.00000f, 2.00000f, 3.00000f, 4.00000f, 5.00000f }
+float farr[] = {0.,1.,2.,3.,4.,5.} // CHECK: (float [6]) { 0.{{0+}}f, 1.{{0+}}f, 2.{{0+}}f, 3.{{0+}}f, 4.{{0+}}f, 5.{{0+}}f }
 std::string sarr[3] = {"A", "B", "C"} // CHECK: (std::string [3]) { "A", "B", "C" }
 
 typedef void (*F_t)(int);
diff --git a/interpreter/cling/test/Prompt/ValuePrinter/Regression.C b/interpreter/cling/test/Prompt/ValuePrinter/Regression.C
index 1385ff0f91d..49265a4329e 100644
--- a/interpreter/cling/test/Prompt/ValuePrinter/Regression.C
+++ b/interpreter/cling/test/Prompt/ValuePrinter/Regression.C
@@ -6,7 +6,7 @@
 // LICENSE.TXT for details.
 //------------------------------------------------------------------------------
 
-// RUN: cat %s | %cling | FileCheck %s
+// RUN: cat %s | %cling 2>&1 | FileCheck %s
 
 // This file should be used as regression test for the value printing subsystem
 // Reproducers of fixed bugs should be put here
@@ -56,8 +56,14 @@ nullptr // CHECK: (nullptr_t) nullptr
 true // CHECK: (bool) true
 false // CHECK: (bool) false
 
+unordered_multiset<float> {1} // ROOT-7310
+// expected-error@2 {{use of undeclared identifier 'unordered_multiset'}}
+// expected-error@2 {{expected '(' for function-style cast or type construction}}
+// expected-error@2 {{initializer list cannot be used on the right hand side of operator '>'}}
+
 #include <unordered_set>
-std::unordered_multiset<float> {1} // ROOT-7310
+std::unordered_multiset<float> {1}
+// FIXME: BROKEN_ON_LINUX-CHECK: (std::unordered_multiset<float>) { 1.00000f }
 
 // ROOT-7426
 #include <string>
@@ -67,8 +73,16 @@ a // CHECK: (std::vector<std::string> &) { "a", "b", "c" }
 a[0] // CHECK: ({{.*}} &) "a"
 
 // ROOT-7918
-enum H {  h = (unsigned long long )-1 };
-h // CHECK: (H) (H::h) : (unsigned long{{( long)?}}) 18446744073709551615
+struct Enumer {
+#ifndef _WIN32
+  // This variant fails on Windows, and seems conforming behaviour to do so
+  enum H {  h = (unsigned long long )-1 };
+#else
+  enum H : unsigned long long { h = (unsigned long long )-1 };
+#endif
+};
+Enumer::h
+// CHECK: (Enumer::H) (Enumer::H::h) : (unsigned long{{( long)?}}) 18446744073709551615
 
 // ROOT-7837
 auto bla=[](double *x, double *par, int blub){return x[0]*blub;} // CHECK: ((lambda) &) @0x
@@ -76,6 +90,12 @@ auto bla=[](double *x, double *par, int blub){return x[0]*blub;} // CHECK: ((lam
 #include <functional>
 using namespace std::placeholders;
 auto fn_moo = std::bind (bla, _1,_2,10) // CHECK: ERROR in cling::executePrintValue(): missing value string.
+// expected-error {{use of undeclared identifier 'lambda'}}
+// expected-error {{expected expression}}
+// expected-error {{type name requires a specifier or qualifier}}
+// expected-error {{expected ')'}}
+// expected-note  {{to match this '('}}
+
 // Make sure cling survives
 12 // CHECK: (int) 12
 
diff --git a/interpreter/cling/test/Prompt/globalinit.C b/interpreter/cling/test/Prompt/globalinit.C
index 88d1314a56b..dd370f2b32d 100644
--- a/interpreter/cling/test/Prompt/globalinit.C
+++ b/interpreter/cling/test/Prompt/globalinit.C
@@ -6,13 +6,20 @@
 // LICENSE.TXT for details.
 //------------------------------------------------------------------------------
 
-// RUN: %cling %s -I%p | FileCheck %s
+// RUN: %cling %s -DTEST_PATH="\"%/p/\"" -Xclang -verify 2>&1 | FileCheck %s
+// RUN: %cling %s -I%p -Xclang -verify 2>&1 | FileCheck %s
 
 #include "cling/Interpreter/Interpreter.h"
 
-void globalinit() {
-  gCling->loadFile("globalinit.C.h", false); // CHECK: A::S()
-  gCling->loadFile("globalinit.C2.h", false); // CHECK: B::S()
+#ifndef TEST_PATH
+  #define TEST_PATH ""
+#endif
+
+void globalinit(const std::string Path = TEST_PATH) {
+  gCling->loadFile(Path + "globalinit.C.h", false); // CHECK: A::S()
+  gCling->loadFile(Path + "globalinit.C2.h", false); // CHECK: B::S()
 }
 // CHECK: B::~S()
 // CHECK: A::~S()
+
+// expected-no-diagnostics
-- 
GitLab