Skip to content

Commit

Permalink
Add Windows only path test cases
Browse files Browse the repository at this point in the history
Windows filepaths support 2 different PathSeparator's (['\\', '/']), we
add some tests to see how interchangeable our stdlib is between mixes of
the two.
  • Loading branch information
Rafflesiaceae committed May 21, 2022
1 parent 40bb560 commit 007c426
Showing 1 changed file with 52 additions and 4 deletions.
56 changes: 52 additions & 4 deletions quicktest.nosh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def remove_file_assert(*paths):

# determine realpath to our tmpdir for cross-plat consistency
git_worktree_toplevel = pwd()
tmpdir = "/tmp/nosh-quicktest"
remove(tmpdir, force=True)
mkdir(tmpdir)
cd(tmpdir)
tmpdir_og = "/tmp/nosh-quicktest"
remove(tmpdir_og, force=True)
mkdir(tmpdir_og)
cd(tmpdir_og)
tmpdir = pwd()
remove(tmpdir)

Expand Down Expand Up @@ -221,6 +221,54 @@ assert(read(otto_subdir_to), "ottrath")

remove_file_assert(otto_to, otto_subdir)

# TEST fs - Windows specifics
if os.isWindows:
assert(cmp_path("/tmp/qwe/asd", "\\tmp\\qwe\\asd"))
assert(cmp_path("/tmp/qwe/asd", "\\tmp/qwe\\asd"))

ottos = [
tmpdir_og+"/otto/neurath",
tmpdir_og+"/otto\\neurath",
tmpdir_og+"\\otto\\neurath",
tmpdir_og+"/otto//neurath",
tmpdir_og+"\\otto\\neurath",

tmpdir_og+"\\neurath\\otto\\",
tmpdir_og+"/neurath\\otto",
]

write(path=ottos[0], contents="neurath")
assert(read(ottos[1]), "neurath")

write(path=ottos[2], contents="otto", force=True)
assert(read(ottos[3]), "otto")

mv(ottos[2], ottos[0], force=True)
assert(read(ottos[1]), "otto")

write(path=ottos[4], contents="notto", force=True)
assert(read(ottos[4]), "notto")

copy(ottos[4], ottos[2], force=True)
assert(read(ottos[2]), "notto")

assert(not exists(ottos[5], dir=True))
assert(not exists(ottos[6], dir=True))
mkdir(ottos[5])
assert(exists(ottos[5], dir=True))
assert(exists(ottos[6], dir=True))

pre_cd = pwd()
cd(ottos[5])
popd()
assert(pwd(), pre_cd)

remove(ottos[6])
assert(not exists(ottos[5], dir=True))

remove(force=True, *ottos)


# TEST os.run - redir/append
otto = fs.join(tmpdir, "otto_neurath")
remove(otto, force=True)
Expand Down

0 comments on commit 007c426

Please sign in to comment.