From 28f23ae668604604bde1a623fd0ad632d68c6121 Mon Sep 17 00:00:00 2001 From: Simon Wright Date: Mon, 1 Jan 2024 10:41:01 +0000 Subject: [PATCH 1/2] 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. --- src/alire/alire-index_on_disk.adb | 2 +- testsuite/tests/index/local-index-not-found/test.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/alire/alire-index_on_disk.adb b/src/alire/alire-index_on_disk.adb index bea0c467d..1260a19e0 100644 --- a/src/alire/alire-index_on_disk.adb +++ b/src/alire/alire-index_on_disk.adb @@ -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; diff --git a/testsuite/tests/index/local-index-not-found/test.py b/testsuite/tests/index/local-index-not-found/test.py index bc571e7ae..2ae98218c 100644 --- a/testsuite/tests/index/local-index-not-found/test.py +++ b/testsuite/tests/index/local-index-not-found/test.py @@ -3,6 +3,7 @@ """ import os +import os.path import re from e3.fs import rm @@ -10,7 +11,6 @@ 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) @@ -21,9 +21,9 @@ path_excerpt = os.path.join('alr-config', 'indexes', 'bad_index', 'index.toml') 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), os.path.sep, d), p.out) print('SUCCESS') From 3a2fba044e088fb8a4ec5ff16bcbde12f6254b2c Mon Sep 17 00:00:00 2001 From: Simon Wright Date: Tue, 2 Jan 2024 11:41:09 +0000 Subject: [PATCH 2/2] Handle Windows separator doubling. --- testsuite/tests/index/local-index-not-found/test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testsuite/tests/index/local-index-not-found/test.py b/testsuite/tests/index/local-index-not-found/test.py index 2ae98218c..69ba36611 100644 --- a/testsuite/tests/index/local-index-not-found/test.py +++ b/testsuite/tests/index/local-index-not-found/test.py @@ -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: .{}{}' '\n' - .format(re.escape(path_excerpt), os.path.sep, d), + .format(re.escape(path_excerpt), separator, d), p.out) print('SUCCESS')