From d40a3c6169f72a23a8255d6b829c1495de082085 Mon Sep 17 00:00:00 2001 From: Simon Wright Date: Sun, 31 Dec 2023 12:49:54 +0000 Subject: [PATCH 1/5] 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 writable directory (e.g. because it doesn't exist), add it to the message in Outcome_Failure. --- src/alire/alire-index_on_disk.adb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 4b7e73aea1296b096a360324a8e5bb364dd00901 Mon Sep 17 00:00:00 2001 From: Simon Wright Date: Sun, 31 Dec 2023 17:42:11 +0000 Subject: [PATCH 2/5] Update test for new 'not a readable directory' report format. * testsuite/tests/index/local-index-not-found/test.py: as summary. --- testsuite/tests/index/local-index-not-found/test.py | 2 +- 1 file changed, 1 insertion(+), 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 bc571e7ae..25704a1db 100644 --- a/testsuite/tests/index/local-index-not-found/test.py +++ b/testsuite/tests/index/local-index-not-found/test.py @@ -21,7 +21,7 @@ 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: ./no-such-directory' '\n' .format(re.escape(path_excerpt)), p.out) From 5c403527ba248e75e0ae6402f1e2e9b3ea54edff Mon Sep 17 00:00:00 2001 From: Simon Wright Date: Sun, 31 Dec 2023 18:50:17 +0000 Subject: [PATCH 3/5] Include test directory in expected text. * testsuite/tests/index/local-index-not-found/test.py: as summary. --- testsuite/tests/index/local-index-not-found/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testsuite/tests/index/local-index-not-found/test.py b/testsuite/tests/index/local-index-not-found/test.py index 25704a1db..100fcb907 100644 --- a/testsuite/tests/index/local-index-not-found/test.py +++ b/testsuite/tests/index/local-index-not-found/test.py @@ -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: ./no-such-directory' + ' Not a readable directory: {}' '\n' - .format(re.escape(path_excerpt)), + .format(re.escape(path_excerpt), d), p.out) print('SUCCESS') From c7221e0a98dfe810d7f00f0c76858629ba896d89 Mon Sep 17 00:00:00 2001 From: Simon Wright Date: Sun, 31 Dec 2023 20:52:05 +0000 Subject: [PATCH 4/5] Make the input directory name match what is expected. * testsuite/tests/index/local-index-not-found/test.py: the input was "no-such-directory", but the output was "./no-such-directory". Fix the input to match that. --- testsuite/tests/index/local-index-not-found/test.py | 2 +- 1 file changed, 1 insertion(+), 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 100fcb907..a7385cbee 100644 --- a/testsuite/tests/index/local-index-not-found/test.py +++ b/testsuite/tests/index/local-index-not-found/test.py @@ -11,7 +11,7 @@ from drivers.asserts import assert_match -for d in ('no-such-directory', +for d in ('./no-such-directory', 'file://no-such-directory', ): rm('alr-config', recursive=True) prepare_indexes('alr-config', '.', From c3be781bbd1f15c1a14fb56e084cce2c10b5ecf4 Mon Sep 17 00:00:00 2001 From: Simon Wright Date: Sun, 31 Dec 2023 22:12:16 +0000 Subject: [PATCH 5/5] Adjust the path for comparison. * testsuite/tests/index/local-index-not-found/test.py (comparator): new. Use when preparing test condition. --- testsuite/tests/index/local-index-not-found/test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/testsuite/tests/index/local-index-not-found/test.py b/testsuite/tests/index/local-index-not-found/test.py index a7385cbee..7f9ff901d 100644 --- a/testsuite/tests/index/local-index-not-found/test.py +++ b/testsuite/tests/index/local-index-not-found/test.py @@ -10,8 +10,13 @@ from drivers.alr import prepare_indexes, run_alr from drivers.asserts import assert_match +def comparator(param): + """If the test value (in d) is 'no-such-directory', the value tested for + is './no-such-directory'; if not, it's left as it is.""" + if param == 'no-such-directory': return './no-such-directory' + return param -for d in ('./no-such-directory', +for d in ('no-such-directory', 'file://no-such-directory', ): rm('alr-config', recursive=True) prepare_indexes('alr-config', '.', @@ -23,7 +28,7 @@ assert_match('ERROR: Cannot load metadata from .*{}:' ' Not a readable directory: {}' '\n' - .format(re.escape(path_excerpt), d), + .format(re.escape(path_excerpt), comparator(d)), p.out) print('SUCCESS')