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
10 changes: 5 additions & 5 deletions ci/expect_scripts/env.exp
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ source ./ci/expect_scripts/shared-code.exp
spawn $env(TESTS_DIR)env

expect "Testing Env module functions..." {
expect -re "Testing Env.cwd!:" {
expect "Testing Env.cwd!:" {
# Match cwd path that has ArbitraryBytes with non-empty list of integers
expect -re {cwd: /[^\r\n]*\r\n} {

expect -re "Testing Env.exe_path!:" {
expect "Testing Env.exe_path!:" {
# Match exe_path with any valid format
expect -re {exe_path: /[^\r\n]*\r\n} {

expect -re "Testing Env.platform!:" {
expect "Testing Env.platform!:" {
# Match platform info with any arch and OS
# Literal braces in regex need to be escaped: \{ and \}
expect -re {Current platform:\{arch: \w+, os: \w+\}} {

expect -re "Testing Env.dict!:" {
expect "Testing Env.dict!:" {
# Match environment variables count as non-zero number
expect -re {Environment variables count: (\d+)} {
set env_count $expect_out(1,string)
Expand All @@ -35,7 +35,7 @@ expect "Testing Env module functions..." {
# Literal brackets [], parentheses (), and quotes "" need escaping or careful handling
expect -re {Sample environment variables:\[\("\w+", ".*"\)(, \("\w+", ".*"\))*\]} {

expect -re "Testing Env.set_cwd!:" {
expect "Testing Env.set_cwd!:" {
# Match changed directory path with non-empty list of integers
expect -re {Changed current directory to: /[^\r\n]*\r\n} {

Expand Down
159 changes: 57 additions & 102 deletions ci/expect_scripts/file.exp
Original file line number Diff line number Diff line change
Expand Up @@ -9,108 +9,63 @@ source ./ci/expect_scripts/shared-code.exp

spawn $env(TESTS_DIR)file

expect "Testing some File functions..." {
expect "This will create and manipulate test files in the current directory." {

# Test File.write_bytes! and File.read_bytes!
expect "Testing File.write_bytes! and File.read_bytes!:" {
expect "Bytes in test_bytes.txt: \\\[72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33\\\]" {

# Test File.write!
expect "Testing File.write!:" {
expect "Content of test_write.json: {\"some\":\"json stuff\"}" {

# Test File.is_file!
expect "Testing File.is_file!:" {
expect "✓ test_bytes.txt is confirmed to be a file" {

# Test File.is_sym_link!
expect "Testing File.is_sym_link!:" {
expect "✓ test_bytes.txt is not a symbolic link" {
expect "✓ test_symlink.txt is a symbolic link" {

# Test File.type!
expect "Testing File.type!:" {
expect "test_bytes.txt file type: IsFile" {
expect ". file type: IsDir" {
expect "test_symlink.txt file type: IsSymLink" {

# Test File.open_reader_with_capacity!
expect "Testing File.open_reader_with_capacity!:" {
expect "✓ Successfully opened reader with 3 byte capacity" {

# Test reading lines from file
expect "Reading lines from file:" {
expect "Line 1: First line" {
expect "" {
expect "Line 2: Second line" {
expect "" {

# Test File.hard_link!
expect "Testing File.hard_link!:" {
expect "✓ Successfully created hard link: test_link_to_original.txt" {
expect "Hard link inodes should be equal: Bool.true" {
expect "✓ Hard link contains same content as original" {

# Test File.rename!
expect "Testing File.rename!:" {
expect "✓ Successfully renamed test_rename_original.txt to test_rename_new.txt" {
expect "✓ Original file test_rename_original.txt no longer exists" {
expect "✓ Renamed file test_rename_new.txt exists" {
expect "✓ Renamed file has correct content" {

# Test File.exists!
expect "Testing File.exists!:" {
expect "✓ File.exists! returns true for a file that exists" {
expect "✓ File.exists! returns false for a file that does not exist" {

expect "I ran all file function tests." {

expect "Cleaning up test files..." {
expect "✓ Deleted all files." {

# Final completion message

expect eof {
check_exit_and_segfault
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
set expected_output [normalize_output "
Testing some File functions...
This will create and manipulate test files in the current directory.

Testing File.write_bytes! and File.read_bytes!:
Bytes in test_bytes.txt: \\\[72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33\\\]

Testing File.write!:
Content of test_write.json: {\"some\":\"json stuff\"}

Testing File.is_file!:
✓ test_bytes.txt is confirmed to be a file

Testing File.is_sym_link!:
✓ test_bytes.txt is not a symbolic link
✓ test_symlink.txt is a symbolic link

Testing File.type!:
test_bytes.txt file type: IsFile
. file type: IsDir
test_symlink.txt file type: IsSymLink

Testing File.open_reader_with_capacity!:
✓ Successfully opened reader with 3 byte capacity

Reading lines from file:
Line 1: First line

Line 2: Second line


Testing File.hard_link!:
✓ Successfully created hard link: test_link_to_original.txt
Hard link inodes should be equal: Bool.true
✓ Hard link contains same content as original

Testing File.rename!:
✓ Successfully renamed test_rename_original.txt to test_rename_new.txt
✓ Original file test_rename_original.txt no longer exists
✓ Renamed file test_rename_new.txt exists
✓ Renamed file has correct content

Testing File.exists!:
✓ File.exists! returns true for a file that exists
✓ File.exists! returns false for a file that does not exist

I ran all file function tests.

Cleaning up test files...
✓ Deleted all files.
"]

expect -re $expected_output {
expect eof {
check_exit_and_segfault
}
}

puts stderr "\nExpect script failed: output was different from expected value. uncomment `exp_internal 1` to debug."
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
32 changes: 16 additions & 16 deletions ci/expect_scripts/sqlite.exp
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ set env(DB_PATH) $env(TESTS_DIR)test.db

spawn $env(TESTS_DIR)sqlite

expect -exact "Rows: {col_bytes: \[72, 101, 108, 108, 111\], col_f32: 78.9, col_f64: 123.456, col_i16: 1234, col_i32: 123456, col_i8: 123, col_nullable_bytes: (NotNull \[119, 111, 114, 108, 100\]), col_nullable_f32: (NotNull 12.34), col_nullable_f64: (NotNull 456.789), col_nullable_i16: (NotNull 5678), col_nullable_i32: (NotNull 456789), col_nullable_i64: (NotNull 987654321), col_nullable_i8: (NotNull 56), col_nullable_str: (NotNull \"nullable text\"), col_nullable_u16: (NotNull 8765), col_nullable_u32: (NotNull 987654), col_nullable_u64: (NotNull 123456789), col_nullable_u8: (NotNull 78), col_text: \"example text\", col_u16: 4321, col_u32: 654321, col_u8: 234}\r\n{col_bytes: \[119, 111, 114, 108, 100\], col_f32: 23.45, col_f64: 456.789, col_i16: 5678, col_i32: 789012, col_i8: 45, col_nullable_bytes: Null, col_nullable_f32: (NotNull 67.89), col_nullable_f64: Null, col_nullable_i16: Null, col_nullable_i32: (NotNull 123456), col_nullable_i64: Null, col_nullable_i8: Null, col_nullable_str: Null, col_nullable_u16: Null, col_nullable_u32: (NotNull 654321), col_nullable_u64: Null, col_nullable_u8: Null, col_text: \"sample text\", col_u16: 9876, col_u32: 1234567, col_u8: 123}\r\n" {
expect "Row count: 2\r\n" {
expect -exact "Updated rows: \[\"Updated text 1\", \"Updated text 2\"\]\r\n" {
expect -exact "Tagged value test: \[(String \"example text\"), (String \"sample text\")\]\r\n" {
expect "Error: Mismatch: Data type mismatch\r\n" {
expect "Success!\r\n" {
expect eof {
check_exit_and_segfault
}
}
}
}
}
}
}
#}
set expected_output [normalize_output "
Rows: {col_bytes: \\\[72, 101, 108, 108, 111\\\], col_f32: 78.9, col_f64: 123.456, col_i16: 1234, col_i32: 123456, col_i8: 123, col_nullable_bytes: (NotNull \\\[119, 111, 114, 108, 100\\\]), col_nullable_f32: (NotNull 12.34), col_nullable_f64: (NotNull 456.789), col_nullable_i16: (NotNull 5678), col_nullable_i32: (NotNull 456789), col_nullable_i64: (NotNull 987654321), col_nullable_i8: (NotNull 56), col_nullable_str: (NotNull \"nullable text\"), col_nullable_u16: (NotNull 8765), col_nullable_u32: (NotNull 987654), col_nullable_u64: (NotNull 123456789), col_nullable_u8: (NotNull 78), col_text: \"example text\", col_u16: 4321, col_u32: 654321, col_u8: 234}
{col_bytes: \\\[119, 111, 114, 108, 100\\\], col_f32: 23.45, col_f64: 456.789, col_i16: 5678, col_i32: 789012, col_i8: 45, col_nullable_bytes: Null, col_nullable_f32: (NotNull 67.89), col_nullable_f64: Null, col_nullable_i16: Null, col_nullable_i32: (NotNull 123456), col_nullable_i64: Null, col_nullable_i8: Null, col_nullable_str: Null, col_nullable_u16: Null, col_nullable_u32: (NotNull 654321), col_nullable_u64: Null, col_nullable_u8: Null, col_text: \"sample text\", col_u16: 9876, col_u32: 1234567, col_u8: 123}
Row count: 2
Updated rows: \\\[\"Updated text 1\", \"Updated text 2\"\\\]
Tagged value test: \\\[(String \"example text\"), (String \"sample text\")\\\]
Error: Mismatch: Data type mismatch
Success!
"]

expect $expected_output {
expect eof {
check_exit_and_segfault
}
}


puts stderr "\nExpect script failed: output was different from expected value. uncomment `exp_internal 1` to debug."
exit 1
Loading