-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathpath-test.exp
More file actions
109 lines (88 loc) · 3.67 KB
/
Copy pathpath-test.exp
File metadata and controls
109 lines (88 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/expect
# uncomment line below for debugging
# exp_internal 1
set timeout 7
source ./ci/expect_scripts/shared-code.exp
spawn $env(TESTS_DIR)path-test
set expected_output [normalize_output "
Testing Path functions...
This will create and manipulate test files and directories in the current directory.
Testing Path.from_bytes and Path.with_extension:
Created path from bytes: test_path
Path.from_bytes result matches expected: Bool.true
Path with extension: test_file.txt
Extension added correctly: Bool.true
Path with dot and extension: test_file.json
Extension after dot: Bool.true
Path with replaced extension: test_file.new
Extension replaced: Bool.true
Testing Path file operations:
test_path_bytes.txt exists: Bool.true
Bytes written: \\\[72, 101, 108, 108, 111, 44, 32, 80, 97, 116, 104, 33\\\]
Bytes read: \\\[72, 101, 108, 108, 111, 44, 32, 80, 97, 116, 104, 33\\\]
Bytes match: Bool.true
File content via cat: Hello from Path module! 🚀
UTF-8 written: Hello from Path module! 🚀
UTF-8 read: Hello from Path module! 🚀
UTF-8 content matches: Bool.true
JSON content: {\"message\":\"Path test\",\"numbers\":\\\[1,2,3\\\]}
JSON contains 'message' field: Bool.true
JSON contains 'numbers' field: Bool.true
File exists before delete: Bool.true
File exists after delete: Bool.false
Testing Path directory operations:
Created directory: drwxr-xr-x \\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ test_single_dir
Is a directory: Bool.true
Nested directory structure:
test_parent
test_parent/test_child
test_parent/test_child/test_grandchild
Number of directories created: 3
Directory contents:
total \\d+
dr\[-rwx\]+ +\\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ \\.
dr\[-rwx\]+ +\\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ \\.\\.
-\[-rwx\]+ +\\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ file1\\.txt
-\[-rwx\]+ +\\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ file2\\.txt
dr\[-rwx\]+ +\\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ subdir
Empty dir exists before delete: Bool.true
Empty dir exists after delete: Bool.false
Size before delete_all: \\d+\\w*\\s*test_parent
Parent dir exists after delete_all: Bool.false
Testing Path.hard_link!:
Hard link count before: 1
Hard link count after: 2
Original content: Original content for Path hard link test
Link content: Original content for Path hard link test
Content matches: Bool.true
Inode information:
\\d+ -rw-r--r-- \\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ test_path_hardlink\\.txt
\\d+ -rw-r--r-- \\d+ \\w+ (\\w+ )? *\\d+ \\w+ +\\d+ \\d+:\\d+ test_path_original\\.txt
First file inode: \\\[\"\\d+\"\\\]
Second file inode: \\\[\"\\d+\"\\\]
Inodes are equal: Bool.true
Testing Path.rename!:
✓ Original file no longer exists
✓ Renamed file exists
✓ Renamed file has correct content
Testing Path.exists!:
✓ Path.exists! returns true for a file that exists
✓ Path.exists! returns false for a file that does not exist
I ran all Path function tests.
Cleaning up test files...
Files to clean up:
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_bytes\\.txt
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_hardlink\\.txt
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_json\\.json
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_original\\.txt
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_rename_new\\.txt
-rw-r--r-- \\d+ \\w+ \\w+ \\d+ \\w+ +\\d+ \\d+:\\d+ test_path_utf8\\.txt
Files remaining after cleanup: Bool.false
"]
expect -re $expected_output {
expect eof {
check_exit_and_segfault
}
}
puts stderr "\nExpect script failed: output was not as expected. Diff the output with expected_output in this script. Alternatively, uncomment `exp_internal 1` to debug."
exit 1