Skip to content

Commit

Permalink
Fix to Issue#181 (JuliaDynamics#380)
Browse files Browse the repository at this point in the history
* added rstrip() also to both parameters in collect_results!.

* added rstrip() to both parameters in collect_results!.

* Changed projectdir() to always cut off trailing slashes.

* Moved rstrip to the correct place within projectdir().

* Added test to check for the bug.

* Removed my test to make sure the others are working with my changes.

* Set a wrong bracket.

* Readded my test since other tests are still working.

* Changed wording in comment.

* Checking if my test tests correctly.

* Test working as intended!.

* Rewriting test with ending var.

* Working version of the test.

* Removed unnecessary brackets.
  • Loading branch information
Myrkwid authored Mar 14, 2023
1 parent af2af4f commit 266041a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/project_setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function projectdir()
end
dirname(Base.active_project())
end
projectdir(args...) = joinpath(projectdir(), args...)
projectdir(args...) = rstrip(joinpath(projectdir(), args...), '/')


# Generate functions to access the path of default subdirectories.
Expand Down
2 changes: 1 addition & 1 deletion src/result_collection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ In case this operation fails the values will be treated as `missing`.
"""
collect_results!(folder; kwargs...) =
collect_results!(
joinpath(dirname(folder), "results_$(basename(folder)).jld2"),
joinpath(dirname(rstrip(folder, '/')), "results_$(rstrip(basename(folder), '/')).jld2"),
folder; kwargs...)

struct InvalidResultsCollection <: Exception
Expand Down
13 changes: 13 additions & 0 deletions test/update_results_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ cres_relpath = collect_results!(relpathname, folder;
rpath = projectdir())
@info all(startswith.(cres[!,"path"], "data"))

###############################################################################
# Trailing slash in foldername #
###############################################################################

df = collect_results!(datadir("results/")) # This would produce the incorrect file. (Issue#181)

pathtofile=datadir("results/results_.jld2") #
@test !isfile(pathtofile)

if isfile(pathtofile)
rm(pathtofile) # In case this test failed, remove the file to not compromise other tests.
end

###############################################################################
# Include or exclude files #
###############################################################################
Expand Down

0 comments on commit 266041a

Please sign in to comment.