From a834e6f6ba51f5f2fadef04616d087a81a8492a0 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 17 May 2018 12:56:35 +0700 Subject: [PATCH] Add tests for reach_for_running --- test/unit-tests/path.mlt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/unit-tests/path.mlt b/test/unit-tests/path.mlt index 3f01e31b..9eb77b9c 100644 --- a/test/unit-tests/path.mlt +++ b/test/unit-tests/path.mlt @@ -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 . +|}] + +Path.(reach_for_running (relative root "foo") ~from:(Path.relative root "foo")) +[%%expect{| +- : Stdune.Path.t = ./. +|}]