Skip to content

Commit

Permalink
Report the name of an unreadable directory (#1523)
Browse files Browse the repository at this point in the history
* Report the name of an unreadable directory.

  * src/alire/alire-index_on_disk.adb (New_Handler.Process_Local_Index):
      If the Path isn't a readable directory (e.g. because it doesn't
      exist), add it to the message in Outcome_Failure.
  * testsuite/tests/index/local-index-not-found/test.py: updated for
      new 'not a readable directory' report format.

* Handle Windows separator doubling.
  • Loading branch information
simonjwright authored Jan 15, 2024
1 parent a11839b commit ac1b9d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/alire/alire-index_on_disk.adb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ package body Alire.Index_On_Disk is
Dir : constant Virtual_File := Create (+Path);
begin
if not Dir.Is_Directory then
Result := Outcome_Failure ("Not a readable directory");
Result := Outcome_Failure ("Not a readable directory: " & Path);
return New_Invalid_Index;
end if;

Expand Down
7 changes: 4 additions & 3 deletions testsuite/tests/index/local-index-not-found/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"""

import os
import os.path
import re

from e3.fs import rm

from drivers.alr import prepare_indexes, run_alr
from drivers.asserts import assert_match


for d in ('no-such-directory',
'file://no-such-directory', ):
rm('alr-config', recursive=True)
Expand All @@ -20,10 +20,11 @@

path_excerpt = os.path.join('alr-config', 'indexes', 'bad_index',
'index.toml')
separator = re.escape(os.path.sep)
assert_match('ERROR: Cannot load metadata from .*{}:'
' Not a readable directory'
' Not a readable directory: .{}{}'
'\n'
.format(re.escape(path_excerpt)),
.format(re.escape(path_excerpt), separator, d),
p.out)

print('SUCCESS')

0 comments on commit ac1b9d7

Please sign in to comment.