Skip to content

Commit ab2ad47

Browse files
committed
more macos fixes
1 parent 43e2113 commit ab2ad47

File tree

3 files changed

+42
-28
lines changed

3 files changed

+42
-28
lines changed

ci/expect_scripts/path-test.exp

100644100755
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ test_parent/test_child/test_grandchild
4545
Number of directories created: 3
4646
Directory contents:
4747
total \\d+
48-
dr\[-rwx\]+ +\\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ \\.
49-
dr\[-rwx\]+ +\\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ \\.\\.
50-
-\[-rwx\]+ +\\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ file1\\.txt
51-
-\[-rwx\]+ +\\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ file2\\.txt
52-
dr\[-rwx\]+ +\\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ subdir
48+
d.* \\.
49+
d.* \\.\\.
50+
-.* file1\\.txt
51+
-.* file2\\.txt
52+
d.* subdir
5353

5454
Empty dir was deleted: Bool.true
55-
Size before delete_all: \\d+\\w*\\s*test_parent
55+
Size before delete_all:\\s*\\d+\\w*\\s*test_parent
5656

5757
Parent dir no longer exists: Bool.true
5858

@@ -63,8 +63,8 @@ Original content: Original content for Path hard link test
6363
Link content: Original content for Path hard link test
6464
Content matches: Bool.true
6565
Inode information:
66-
\\d+ -rw-r--r-- \\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ test_path_hardlink\\.txt
67-
\\d+ -rw-r--r-- \\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ test_path_original\\.txt
66+
\\d+ .* test_path_hardlink\\.txt
67+
\\d+ .* test_path_original\\.txt
6868

6969
First file inode: \\\[\"\\d+\"\\\]
7070
Second file inode: \\\[\"\\d+\"\\\]
@@ -83,19 +83,19 @@ I ran all Path function tests.
8383

8484
Cleaning up test files...
8585
Files to clean up:
86-
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_bytes\\.txt
87-
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_hardlink\\.txt
88-
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_json\\.json
89-
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_original\\.txt
90-
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_rename_new\\.txt
91-
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_utf8\\.txt
92-
93-
ls: cannot access .*
94-
ls: cannot access .*
95-
ls: cannot access .*
96-
ls: cannot access .*
97-
ls: cannot access .*
98-
ls: cannot access .*
86+
-.* test_path_bytes\\.txt
87+
-.* test_path_hardlink\\.txt
88+
-.* test_path_json\\.json
89+
-.* test_path_original\\.txt
90+
-.* test_path_rename_new\\.txt
91+
-.* test_path_utf8\\.txt
92+
93+
ls: .*
94+
ls: .*
95+
ls: .*
96+
ls: .*
97+
ls: .*
98+
ls: .*
9999
Files deleted successfully: Bool.true
100100
"]
101101

tests/file.roc

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ main! = |_args|
1616
Ok(_) ->
1717
cleanup_test_files!(FilesNeedToExist)
1818
Err(err) ->
19-
cleanup_test_files!(FilesMaybeExist)?
19+
_ = cleanup_test_files!(FilesMaybeExist)
2020
Err(Exit(1, "Test run failed:\n\t${Inspect.to_str(err)}"))
2121

2222
run_tests! : {} => Result {} _

tests/path-test.roc

100644100755
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ main! = |_args|
1616
Ok(_) ->
1717
cleanup_test_files!(FilesNeedToExist)
1818
Err(err) ->
19-
cleanup_test_files!(FilesMaybeExist)?
19+
_ = cleanup_test_files!(FilesMaybeExist)
2020
Err(Exit(1, "Test run failed:\n\t${Inspect.to_str(err)}"))
2121

2222
run_tests!: {} => Result {} _
@@ -247,6 +247,21 @@ test_directory_operations! = |{}|
247247
248248
Ok({})
249249
250+
get_hard_link_count! : Str => Result Str _
251+
get_hard_link_count! = |path_str|
252+
ls_l =
253+
Cmd.new("ls")
254+
|> Cmd.args(["-l", path_str])
255+
|> Cmd.exec_output!()?
256+
257+
hard_link_count_str =
258+
(ls_l.stdout_utf8
259+
|> Str.split_on(" ")
260+
|> List.keep_if(|str| !Str.is_empty(str))
261+
|> List.get(1)) ? |_| IExpectedALineWithASpaceHere(ls_l)
262+
263+
Ok(hard_link_count_str)
264+
250265
test_hard_link! : {} => Result {} _
251266
test_hard_link! = |{}|
252267
Stdout.line!("\nTesting Path.hard_link!:")?
@@ -255,24 +270,23 @@ test_hard_link! = |{}|
255270
original_path = Path.from_str("test_path_original.txt")
256271
Path.write_utf8!("Original content for Path hard link test", original_path)?
257272
258-
# Get original file stats
259-
stat_before = Cmd.new("stat") |> Cmd.args(["-c", "%h", "test_path_original.txt"]) |> Cmd.exec_output!()?
273+
hard_link_count_before = get_hard_link_count!("test_path_original.txt")?
260274
261275
# Create hard link
262276
link_path = Path.from_str("test_path_hardlink.txt")
263277
when Path.hard_link!(original_path, link_path) is
264278
Ok({}) ->
265279
# Get link count after
266-
stat_after = Cmd.new("stat") |> Cmd.args(["-c", "%h", "test_path_original.txt"]) |> Cmd.exec_output!()?
280+
hard_link_count_after = get_hard_link_count!("test_path_original.txt")?
267281
268282
# Verify both files exist and have same content
269283
original_content = Path.read_utf8!(original_path)?
270284
link_content = Path.read_utf8!(link_path)?
271285
272286
Stdout.line!(
273287
"""
274-
Hard link count before: ${Str.trim(stat_before.stdout_utf8)}
275-
Hard link count after: ${Str.trim(stat_after.stdout_utf8)}
288+
Hard link count before: ${hard_link_count_before}
289+
Hard link count after: ${hard_link_count_after}
276290
Original content: ${original_content}
277291
Link content: ${link_content}
278292
Content matches: ${Inspect.to_str(original_content == link_content)}

0 commit comments

Comments
 (0)