From 57382b199b613167fe14d0f82cd98c19acb77bdc Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 18 Jan 2022 11:16:17 +0100
Subject: [PATCH] [T] Fix notebook tests on Windows.

---
 Tests/Data/Notebooks/requirements.txt   |  2 +-
 scripts/cmake/test/NotebookTest.cmake   | 20 +++++++++++++++++---
 scripts/cmake/test/OgsTestWrapper.cmake |  2 +-
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/Tests/Data/Notebooks/requirements.txt b/Tests/Data/Notebooks/requirements.txt
index f4919231d8b..fabac81ff07 100644
--- a/Tests/Data/Notebooks/requirements.txt
+++ b/Tests/Data/Notebooks/requirements.txt
@@ -1,4 +1,4 @@
-https://github.com/joergbuchwald/ogs6py/archive/refs/heads/master.zip
+https://github.com/joergbuchwald/ogs6py/archive/0f9e738e2ee469c8bde4204b2151238973417694.zip
 https://github.com/joergbuchwald/VTUinterface/archive/refs/heads/master.zip
 https://github.com/bilke/nb2hugo/archive/e27dc02df2be1ce19e4a6f52d197c2e2a6ca520c.zip
 ipykernel
diff --git a/scripts/cmake/test/NotebookTest.cmake b/scripts/cmake/test/NotebookTest.cmake
index c2e2d51b139..0d5ad921195 100644
--- a/scripts/cmake/test/NotebookTest.cmake
+++ b/scripts/cmake/test/NotebookTest.cmake
@@ -1,4 +1,4 @@
-# cmake-lint: disable=C0103
+# cmake-lint: disable=C0103,R0915
 function(NotebookTest)
 
     if(NOT OGS_BUILD_CLI OR NOT OGS_BUILD_TESTING OR NOT OGS_TEST_NOTEBOOKS)
@@ -74,10 +74,24 @@ function(NotebookTest)
         list(APPEND labels large)
     endif()
 
+    if(MSVC AND ${CMAKE_VERSION} VERSION_LESS 3.22)
+        message(
+            WARNING "Notebook tests are disabled on Windows when CMake < 3.22!"
+        )
+        return()
+    endif()
+
+    if(${CMAKE_VERSION} VERSION_LESS 3.22)
+        set(_prop_env ENVIRONMENT PATH=$<TARGET_FILE_DIR:ogs>:$ENV{PATH})
+    else()
+        set(_prop_env ENVIRONMENT_MODIFICATION
+                      PATH=path_list_prepend:$<TARGET_FILE_DIR:ogs>
+        )
+    endif()
+
     set_tests_properties(
         ${TEST_NAME}
-        PROPERTIES ENVIRONMENT
-                   PATH=$<TARGET_FILE_DIR:ogs>:$ENV{PATH}
+        PROPERTIES ${_prop_env}
                    COST
                    ${NotebookTest_RUNTIME}
                    DISABLED
diff --git a/scripts/cmake/test/OgsTestWrapper.cmake b/scripts/cmake/test/OgsTestWrapper.cmake
index 84dee510960..b80b75671a8 100644
--- a/scripts/cmake/test/OgsTestWrapper.cmake
+++ b/scripts/cmake/test/OgsTestWrapper.cmake
@@ -7,7 +7,7 @@ execute_process(
 )
 
 if(EXIT_CODE STREQUAL "0")
-    if(NOT DEFINED ENV{CI})
+    if(NOT DEFINED ENV{CI} AND NOT CAT_LOG)
         file(WRITE ${LOG_FILE} "${LOG}")
     endif()
 else()
-- 
GitLab