Skip to content

Commit

Permalink
Adding windows testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mwestphal committed Mar 23, 2024
1 parent c126e03 commit 27feac3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
12 changes: 9 additions & 3 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,13 @@ if(NOT F3D_MACOS_BUNDLE)
endif()
endif()

if(UNIX AND NOT VTK_OPENGL_HAS_EGL)
# Custom bash test for testing watch option
add_test (NAME f3d::TestWatch COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_watch.sh $<TARGET_FILE:f3d> ${F3D_SOURCE_DIR}/testing/data ${CMAKE_BINARY_DIR}/Testing/Temporary)
if(NOT VTK_OPENGL_HAS_EGL)
if(UNIX)
# Custom bash test for testing watch option
add_test (NAME f3d::TestWatch COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_watch.sh $<TARGET_FILE:f3d> ${F3D_SOURCE_DIR}/testing/data ${CMAKE_BINARY_DIR}/Testing/Temporary)
elseif(WIN32)
find_program(PWSH NAMES pwsh powershell)
add_test (NAME f3d::TestWatch COMMAND ${PWSH} ${CMAKE_CURRENT_SOURCE_DIR}/test_watch.ps1 $<TARGET_FILE:f3d> ${F3D_SOURCE_DIR}/testing/data ${CMAKE_BINARY_DIR}/Testing/Temporary)
elseif(UNIX)
endif()
endif()
30 changes: 30 additions & 0 deletions application/testing/test_watch.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Test the watch feature by opening a file
# rewriting it and checking the the file has been
# automatically reloaded

$f3d_cmd = $args[0]
$data_dir = $args[1]
$tmp_dir = $args[2]

$hires_data = "$data_dir/cow.vtp"
$lowres_data = "$data_dir/cowlow.vtp"
$reloaded_data = "$tmp_dir/cow.vtp"

Copy-Item $hires_data -Destination $reloaded_data

$log = "$tmp_dir/output.log"
$id = (Start-Process -FilePath $f3d_cmd -ArgumentList "--watch --verbose $reloaded_data" -RedirectStandardOutput $log -PassThru).Id

Start-Sleep -Seconds 1
Copy-Item $lowres_data -Destination $reloaded_data
Start-Sleep -Seconds 1

$str = Select-String $log -Pattern "Number of points: 634"
if ($str -ne $null) {
$ret = 0
} else {
$ret = 1
}

Stop-Process -Id $id
exit $ret

0 comments on commit 27feac3

Please sign in to comment.