diff --git a/ci/expect_scripts/env.exp b/ci/expect_scripts/env.exp index 463082d7..975da4ea 100644 --- a/ci/expect_scripts/env.exp +++ b/ci/expect_scripts/env.exp @@ -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) @@ -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} { diff --git a/ci/expect_scripts/file.exp b/ci/expect_scripts/file.exp index 35af6cd8..66a0e077 100644 --- a/ci/expect_scripts/file.exp +++ b/ci/expect_scripts/file.exp @@ -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 \ No newline at end of file diff --git a/ci/expect_scripts/sqlite.exp b/ci/expect_scripts/sqlite.exp index e20c07c3..318908a3 100644 --- a/ci/expect_scripts/sqlite.exp +++ b/ci/expect_scripts/sqlite.exp @@ -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 \ No newline at end of file diff --git a/ci/expect_scripts/url.exp b/ci/expect_scripts/url.exp index e2cc6a0c..c5e7d0cc 100644 --- a/ci/expect_scripts/url.exp +++ b/ci/expect_scripts/url.exp @@ -9,81 +9,60 @@ source ./ci/expect_scripts/shared-code.exp spawn $env(TESTS_DIR)url -expect "Testing Url module functions..." { - expect "Created URL: https://example.com" { - expect "Testing Url.append:" { - expect "URL with append: https://example.com/some%20stuff" { - expect "URL with query and fragment, then appended path: https://example.com/stuff?search=blah#fragment" { - expect "URL with multiple appended paths: https://example.com/things/stuff/more/etc/" { - expect "Testing Url.append_param:" { - expect "URL with appended param: https://example.com?email=someone%40example.com" { - expect "URL with multiple appended params: https://example.com?caf%C3%A9=du%20Monde&email=hi%40example.com" { - expect "Testing Url.has_query:" { - expect "URL with query has_query: Bool.true" { - expect "URL without query has_query: Bool.false" { - expect "Testing Url.has_fragment:" { - expect "URL with fragment has_fragment: Bool.true" { - expect "URL without fragment has_fragment: Bool.false" { - expect "Testing Url.query:" { - expect "Query from URL: key1=val1&key2=val2&key3=val3" { - expect "Query from URL without query: " { - expect "Testing Url.fragment:" { - expect "Fragment from URL: stuff" { - expect "Fragment from URL without fragment: " { - expect "Testing Url.reserve:" { - expect "URL with reserved capacity and params: https://example.com/stuff?caf%C3%A9=du%20Monde&email=hi%40example.com" { - expect "Testing Url.with_query:" { - expect "URL with replaced query: https://example.com?newQuery=thisRightHere#stuff" { - expect "URL with removed query: https://example.com#stuff" { - expect "Testing Url.with_fragment:" { - expect "URL with replaced fragment: https://example.com#things" { - expect "URL with added fragment: https://example.com#things" { - expect "URL with removed fragment: https://example.com" { - expect "Testing Url.query_params:" { - expect "params_dict: {\"key1\": \"val1\", \"key2\": \"val2\", \"key3\": \"val3\"}" { - expect "Testing Url.path:" { - expect "Path from URL: example.com/foo/bar" { - expect "Path from relative URL: /foo/bar" { - expect "All tests executed." { - expect eof { - check_exit_and_segfault - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } +set expected_output [normalize_output " +Testing Url module functions... +Created URL: https://example.com +Testing Url.append: +URL with append: https://example.com/some%20stuff +URL with query and fragment, then appended path: https://example.com/stuff\\?search=blah#fragment +URL with multiple appended paths: https://example.com/things/stuff/more/etc/ +Testing Url.append_param: +URL with appended param: https://example.com\\?email=someone%40example.com +URL with multiple appended params: https://example.com\\?caf%C3%A9=du%20Monde&email=hi%40example.com + +Testing Url.has_query: +URL with query has_query: Bool.true +URL without query has_query: Bool.false + +Testing Url.has_fragment: +URL with fragment has_fragment: Bool.true +URL without fragment has_fragment: Bool.false + +Testing Url.query: +Query from URL: key1=val1&key2=val2&key3=val3 +Query from URL without query: + +Testing Url.fragment: +Fragment from URL: stuff +Fragment from URL without fragment: + +Testing Url.reserve: +URL with reserved capacity and params: https://example.com/stuff\\?caf%C3%A9=du%20Monde&email=hi%40example.com + +Testing Url.with_query: +URL with replaced query: https://example.com\\?newQuery=thisRightHere#stuff +URL with removed query: https://example.com#stuff + +Testing Url.with_fragment: +URL with replaced fragment: https://example.com#things +URL with added fragment: https://example.com#things +URL with removed fragment: https://example.com + +Testing Url.query_params: +params_dict: {\"key1\": \"val1\", \"key2\": \"val2\", \"key3\": \"val3\"} + +Testing Url.path: +Path from URL: example.com/foo/bar +Path from relative URL: /foo/bar + +All tests executed. +"] + +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 \ No newline at end of file