rewrite prop_relPathDirToFileAbs_basics

This was not a good test, it broke the requirement that
relPathDirToFileAbs take absolute paths. And it failed when the two
input paths were eg, the same but differently normalized.

Replaced with some tests of the real basics of that function.
This commit is contained in:
Joey Hess 2021-01-13 13:21:15 -04:00
parent 6c8205a113
commit 99ba471209
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 21 additions and 11 deletions

View file

@ -189,8 +189,7 @@ splitShortExtensions' maxextension = go []
(base, ext) = splitExtension f
len = B.length ext
{- This requires the first path to be absolute, and the
- second path cannot contain ../ or ./
{- This requires both paths to be absolute and normalized.
-
- On Windows, if the paths are on different drives,
- a relative path is not possible and the path is simply

View file

@ -35,16 +35,14 @@ prop_upFrom_basics tdir
p = fromRawFilePath <$> upFrom (toRawFilePath dir)
dir = fromTestableFilePath tdir
prop_relPathDirToFileAbs_basics :: TestableFilePath -> TestableFilePath -> Bool
prop_relPathDirToFileAbs_basics fromt tot
| from == to = null r
| otherwise = not (null r)
prop_relPathDirToFileAbs_basics :: TestableFilePath -> Bool
prop_relPathDirToFileAbs_basics pt = and
[ relPathDirToFileAbs p (p </> "bar") == "bar"
, relPathDirToFileAbs (p </> "bar") p == ".."
, relPathDirToFileAbs p p == ""
]
where
from = fromTestableFilePath fromt
to = fromTestableFilePath tot
r = fromRawFilePath $ relPathDirToFileAbs
(toRawFilePath from)
(toRawFilePath to)
p = pathSeparator `B.cons` toRawFilePath (fromTestableFilePath pt)
prop_relPathDirToFileAbs_regressionTest :: Bool
prop_relPathDirToFileAbs_regressionTest = same_dir_shortcurcuits_at_difference

View file

@ -14,3 +14,5 @@ Fresh build of 8.20201129+git100-g2d84bf992-1~ndall+1 when having HOME (base sys
[[!meta author=yoh]]
[[!tag projects/datalad]]
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,11 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2021-01-13T17:01:07Z"
content="""
This is a pure test, and the filesystem does not affect it in any way.
The test is slightly broken, in that when two paths
are the same except slightly differently normalized (eg, "A" vs "A/"),
it fails. Really not a great test overall, rewriting.
"""]]