Add tests for reach_for_running

This commit is contained in:
Rudi Grinberg 2018-05-17 12:56:35 +07:00
parent 9fbfc272eb
commit a834e6f6ba
1 changed files with 28 additions and 0 deletions

View File

@ -284,3 +284,31 @@ Path.is_in_build_dir Path.build_dir
[%%expect{|
- : bool = false
|}]
Path.reach_for_running Path.build_dir ~from:Path.root
[%%expect{|
- : Stdune.Path.t = ./_build
|}]
Path.(reach_for_running (relative build_dir "foo/baz")
~from:(relative build_dir "foo/bar/baz"))
[%%expect{|
- : Stdune.Path.t = ../../baz
|}]
Path.(reach_for_running (Path.absolute "/fake/path")
~from:(relative build_dir "foo/bar/baz"))
[%%expect{|
- : Stdune.Path.t = /fake/path
|}]
Path.(reach_for_running (relative build_dir "foo/baz")
~from:(Path.absolute "/fake/path"))
[%%expect{|
Exception: Stdune__Exn.Code_error <abstr>.
|}]
Path.(reach_for_running (relative root "foo") ~from:(Path.relative root "foo"))
[%%expect{|
- : Stdune.Path.t = ./.
|}]