11module mcl.utils.path ;
2- import mcl.utils.test;
32
43import std.process : execute;
54import std.string : strip;
65import std.file : mkdirRecurse, rmdir, exists;
7- import std.path : buildPath ;
6+ import std.path : buildNormalizedPath, absolutePath ;
87
98immutable string rootDir, resultDir, gcRootsDir;
109
1110shared static this ()
1211{
1312 rootDir = getTopLevel();
14- resultDir = rootDir.buildPath (" .result" );
15- gcRootsDir = resultDir.buildPath (" gc-roots" );
13+ resultDir = rootDir.buildNormalizedPath (" .result" );
14+ gcRootsDir = resultDir.buildNormalizedPath (" gc-roots" );
1615}
1716
1817string getTopLevel ()
@@ -23,7 +22,11 @@ string getTopLevel()
2322 if (isNixbld)
2423 return environment[" NIX_BUILD_TOP" ];
2524
26- return execute ([" git" , " rev-parse" , " --show-toplevel" ]).output.strip;
25+ auto res = execute([" git" , " rev-parse" , " --show-toplevel" ]);
26+ if (res.status != 0 )
27+ return " ." .absolutePath.buildNormalizedPath;
28+
29+ return res.output.strip;
2730}
2831
2932@(" rootDir" )
@@ -35,13 +38,13 @@ unittest
3538@(" resultDir" )
3639unittest
3740{
38- assert (resultDir == rootDir.buildPath (" .result" ));
41+ assert (resultDir == rootDir.buildNormalizedPath (" .result" ));
3942}
4043
4144@(" gcRootsDir" )
4245unittest
4346{
44- assert (gcRootsDir == resultDir.buildPath (" gc-roots" ));
47+ assert (gcRootsDir == resultDir.buildNormalizedPath (" gc-roots" ));
4548}
4649
4750void createResultDirs ()
0 commit comments