Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
r2ogs6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
OpenGeoSys Tools
r2ogs6
Commits
768a0ed0
Commit
768a0ed0
authored
3 years ago
by
Johannes Boog
Browse files
Options
Downloads
Plain Diff
Merge branch '47-add-security-routine-for-output-file-import' into 'master'
Resolve "Add security routine for output file import" Closes
#47
See merge request
!32
parents
9a55506a
35aa37d5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!32
Resolve "Add security routine for output file import"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/sim_utils.R
+12
-3
12 additions, 3 deletions
R/sim_utils.R
tests/testthat/test-sim_utils.R
+25
-0
25 additions, 0 deletions
tests/testthat/test-sim_utils.R
with
37 additions
and
3 deletions
R/sim_utils.R
+
12
−
3
View file @
768a0ed0
...
@@ -246,13 +246,22 @@ ogs6_read_output_files <- function(ogs6_obj){
...
@@ -246,13 +246,22 @@ ogs6_read_output_files <- function(ogs6_obj){
pvd_paths
<-
list.files
(
ogs6_obj
$
sim_path
,
pvd_paths
<-
list.files
(
ogs6_obj
$
sim_path
,
"\\.pvd$"
,
"\\.pvd$"
,
full.names
=
TRUE
)
full.names
=
TRUE
)
# Wait for eventual file writing processes to finish
ogs6_obj
$
pvds
<-
lapply
(
pvd_paths
,
function
(
x
){
OGS6_pvd
$
new
(
pvd_path
=
x
)})
t0
<-
Sys.time
()
while
(((
length
(
pvd_paths
)
==
0
)
|
any
(
file.size
(
pvd_paths
)
<=
64
))
&
difftime
(
Sys.time
(),
t0
,
units
=
"secs"
)
<
2
)
{
Sys.sleep
(
0.01
)
}
if
(((
length
(
pvd_paths
)
==
0
)
|
any
(
file.size
(
pvd_paths
)
<=
64
)))
{
stop
(
"Output file not written out correctly.
Unable to import *.pvd"
)
}
else
{
ogs6_obj
$
pvds
<-
lapply
(
pvd_paths
,
function
(
x
){
OGS6_pvd
$
new
(
pvd_path
=
x
)})
}
return
(
invisible
())
return
(
invisible
())
}
}
#===== Test benchmarks =====
#===== Test benchmarks =====
...
...
This diff is collapsed.
Click to expand it.
tests/testthat/test-sim_utils.R
+
25
−
0
View file @
768a0ed0
...
@@ -81,6 +81,31 @@ test_that("ogs6_export_sim_files works", {
...
@@ -81,6 +81,31 @@ test_that("ogs6_export_sim_files works", {
unlink
(
test_path
,
recursive
=
TRUE
)
unlink
(
test_path
,
recursive
=
TRUE
)
})
})
test_that
(
"Nonexistent *.pvd file yields an appropriate error"
,
{
sim_path
<-
paste0
(
tmp_dir
,
"/run_simulation_test"
)
dir.create
(
sim_path
)
# create empty ogs6 object
ogs6_obj
<-
OGS6
$
new
(
sim_name
=
"sim"
,
sim_path
=
sim_path
)
expect_error
(
ogs6_read_output_files
(
ogs6_obj
))
unlink
(
sim_path
,
recursive
=
TRUE
)
})
test_that
(
"Small *.pvd file yields an appropriate error"
,
{
sim_path
<-
paste0
(
tmp_dir
,
"/run_simulation_test"
)
dir.create
(
sim_path
)
d
<-
NULL
save
(
d
,
file
=
paste0
(
sim_path
,
"/null.pvd"
))
# create empty ogs6 object
ogs6_obj
<-
OGS6
$
new
(
sim_name
=
"sim"
,
sim_path
=
sim_path
)
expect_error
(
ogs6_read_output_files
(
ogs6_obj
))
unlink
(
sim_path
,
recursive
=
TRUE
)
})
#===== Test benchmarks =====
#===== Test benchmarks =====
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment