Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ajunitgen = "^1.0.1"
ansiada = "^1.1"
c_strings = "^1.0"
clic = "~0.3"
den = "~0.1"
den = "~0.2"
dirty_booleans = "~0.1"
diskflags = "~0.1"
gnatcoll = "^21"
Expand Down Expand Up @@ -76,7 +76,7 @@ commit = "56bbdc008e16996b6f76e443fd0165a240de1b13"

[pins.den]
url = "https://github.com/mosteo/den"
commit = "7732f9247f7436cd264a10a7e2a8a16c47a0fb57"
commit = "bab6ef56b74b3b348daf402f09f4b04c304bc280"

[pins.dirty_booleans]
url = "https://github.com/mosteo/dirty_booleans"
Expand Down
18 changes: 12 additions & 6 deletions src/alire/alire-directories.adb
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,24 @@ package body Alire.Directories is
return Any_Path
is
begin
if Path /= Den.Scrub (Path) then
return Find_Candidate_Folder (Den.Scrub (Path));
end if;

Trace.Debug ("Looking for alire metadata at: " & Path);
if
Exists (Path / Paths.Crate_File_Name) and then
Kind (Path / Paths.Crate_File_Name) = File
then
return Path;
elsif Den.Has_Parent (Path) then
return Find_Candidate_Folder
(Den.Parent (Path));
else
return Find_Candidate_Folder (Adirs.Containing_Directory (Path));
end if;
exception
when Adirs.Use_Error =>
Trace.Debug
("Root directory reached without finding alire metadata");
return ""; -- There's no containing folder (hence we're at root)
return ""; -- No containing folder
end if;
end Find_Candidate_Folder;

begin
Expand Down Expand Up @@ -514,7 +518,9 @@ package body Alire.Directories is
------------

function Exists (Path : Any_Path) return Boolean
is (Den.Exists (Den.Scrub (Path)));
is (Den.Exists
(Den.Scrub
(Path)));

------------------
-- Is_Directory --
Expand Down
2 changes: 1 addition & 1 deletion testsuite/drivers/asserts.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def match_deploy_dir(crate : str, path_fragment : str):

def assert_substring(target: str, text: str):
"""
Check that a string is contained in another string
Check that a target string is contained in a given text
"""
assert target in text, \
f"Missing expected string '{target}' in text:\n{text}"
Expand Down
31 changes: 31 additions & 0 deletions testsuite/tests/misc/other-slash-in-path/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Check that slashes from other OSes in paths are handled correctly.
Fix for issue #1984
"""

import os
from drivers.alr import run_alr
from drivers.asserts import assert_eq, assert_substring
from drivers.helpers import on_windows

BAD_SLASH = '/' if on_windows() else '\\'
BAD_DIR = f"test{BAD_SLASH}crate"
START_DIR = os.getcwd()

# Initialize a crate in place within a directory with the contrary slash
# to the one used by the current OS.

os.mkdir(BAD_DIR)
os.chdir(BAD_DIR)
run_alr("init", "testcrate", "--bin", "--in-place")

# Check we are were we expect to be
assert_eq(os.getcwd(), os.path.join(START_DIR, BAD_DIR))

# Check that it can be shown
p = run_alr("show")

# Verify the crate name is in the output
assert_substring("testcrate=0.1.0-dev", p.out)

print("SUCCESS")
6 changes: 6 additions & 0 deletions testsuite/tests/misc/other-slash-in-path/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
driver: python-script
control:
- [SKIP, "skip_unix", "Test is Unix-only"]
# Windows won't allow either '\' or '/' in filenames and directory names
indexes:
compiler_only_index: {}