Skip to content

Commit

Permalink
Disable tests for DirectoryHome, DirectoryDesktop
Browse files Browse the repository at this point in the history
These tests are not very important, but easily break -- e.g there might
be no "desktop directory". Also, guix sets HOME to an invalid directory
path *on purpose*, GAP works 100% in this setting, *except* for this
test.

In the other direction, I don't really see anything we can from this
test, so instead of trying to fiddle around with it, I decided to just
scrap it.

At the same time, let's make the code a little bit more robust in
case HOME is not even set.
  • Loading branch information
fingolfin authored and ChrisJefferson committed Oct 13, 2023
1 parent a8bd423 commit d284d81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
20 changes: 9 additions & 11 deletions lib/files.gi
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,10 @@ end);

InstallGlobalFunction(DirectoryHome,function()
local a,h,d;
if ARCH_IS_WINDOWS() then
h:=StringHOMEPath();
h:=StringHOMEPath();
if h = fail then
return fail;
elif ARCH_IS_WINDOWS() then
d:=List(DirectoryContents(h),LowercaseString);
a:=First(["My Documents", #en
"Documents", #en-win8
Expand All @@ -322,18 +324,17 @@ local a,h,d;
h := Concatenation(h,"/");
fi;
return Directory(Concatenation(h,a));
else
return Directory(StringHOMEPath());
fi;
else
return Directory(StringHOMEPath());
fi;
return Directory(h);
end);

InstallGlobalFunction(DirectoryDesktop,function()
local a,h,d;
h:=StringHOMEPath();
if ARCH_IS_WINDOWS() then
if h = fail then
return fail;
elif ARCH_IS_WINDOWS() then
d:=List(DirectoryContents(h),LowercaseString);
a:=First(["Desktop",
"Bureau", #fr
Expand All @@ -346,8 +347,6 @@ local a,h,d;
h := Concatenation(h,"/");
fi;
return Directory(Concatenation(h,a));
else
return Directory(StringHOMEPath());
fi;
else
d:=List(DirectoryContents(h),LowercaseString);
Expand All @@ -361,10 +360,9 @@ local a,h,d;
h := Concatenation(h,"/");
fi;
return Directory(Concatenation(h,a));
else
return Directory(h);
fi;
fi;
return Directory(h);
end);

InstallGlobalFunction(RemoveDirectoryRecursively,
Expand Down
5 changes: 3 additions & 2 deletions tst/testinstall/dir.tst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ gap> List(dirs, IsDirectory);
[ false, true, false, true ]
gap> DirectoryHome() = Directory("~") or ARCH_IS_WINDOWS();
true
gap> ForAll([DirectoryHome, DirectoryDesktop,DirectoryCurrent],
> x -> (IsDirectoryPath(x()) and IsDirectory(x())) );
gap> IsDirectoryPath(DirectoryCurrent());
true
gap> IsDirectory(DirectoryCurrent());
true
gap> dirTest := Concatenation(base,"/dir-test");;
gap> SortedList(DirectoryContents(dirTest));
Expand Down

0 comments on commit d284d81

Please sign in to comment.