@@ -8,46 +8,46 @@ fn run_glint_test(fixture_name: &str, expect_success: bool) {
8
8
cmd. arg ( "run" ) ;
9
9
cmd. arg ( "--quiet" ) ;
10
10
cmd. arg ( "--" ) ;
11
-
11
+
12
12
// Get the path to the test fixture
13
13
let fixture_path = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) )
14
14
. join ( "tests" )
15
15
. join ( "fixtures" )
16
16
. join ( fixture_name) ;
17
-
17
+
18
18
cmd. arg ( & fixture_path) ;
19
-
19
+
20
20
let output = cmd. output ( ) . expect ( "Failed to execute glint" ) ;
21
-
21
+
22
22
// Check exit code
23
23
if expect_success {
24
- assert ! ( output. status. success( ) ,
25
- "Expected glint to exit with zero status for {}, got {:?}" ,
24
+ assert ! ( output. status. success( ) ,
25
+ "Expected glint to exit with zero status for {}, got {:?}" ,
26
26
fixture_name, output. status. code( ) ) ;
27
27
} else {
28
- assert ! ( !output. status. success( ) ,
28
+ assert ! ( !output. status. success( ) ,
29
29
"Expected glint to exit with non-zero status for {}" , fixture_name) ;
30
- assert_eq ! ( output. status. code( ) , Some ( 1 ) ,
30
+ assert_eq ! ( output. status. code( ) , Some ( 1 ) ,
31
31
"Expected exit code 1 for {}" , fixture_name) ;
32
32
}
33
-
33
+
34
34
// Parse the actual JSON output
35
35
let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
36
36
let actual_json: Value = serde_json:: from_str ( & stdout)
37
37
. expect ( & format ! ( "Failed to parse JSON output for {}: {}" , fixture_name, stdout) ) ;
38
-
38
+
39
39
// Load expected JSON
40
40
let expected_path = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) )
41
41
. join ( "tests" )
42
42
. join ( "fixtures" )
43
43
. join ( format ! ( "{}.expected.json" , fixture_name) ) ;
44
-
44
+
45
45
let expected_content = fs:: read_to_string ( & expected_path)
46
46
. expect ( & format ! ( "Failed to read expected file: {:?}" , expected_path) ) ;
47
-
47
+
48
48
let mut expected_json: Value = serde_json:: from_str ( & expected_content)
49
49
. expect ( & format ! ( "Failed to parse expected JSON for {}" , fixture_name) ) ;
50
-
50
+
51
51
// Normalize file paths in expected JSON to match actual output
52
52
if let Some ( files) = expected_json. get_mut ( "files" ) . and_then ( |f| f. as_object_mut ( ) ) {
53
53
let mut normalized_files = serde_json:: Map :: new ( ) ;
@@ -61,11 +61,11 @@ fn run_glint_test(fixture_name: &str, expect_success: bool) {
61
61
}
62
62
* files = normalized_files;
63
63
}
64
-
64
+
65
65
// Compare JSON
66
- assert_eq ! ( actual_json, expected_json,
67
- "JSON output mismatch for {}.\n Actual:\n {}\n Expected:\n {}" ,
68
- fixture_name,
66
+ assert_eq ! ( actual_json, expected_json,
67
+ "JSON output mismatch for {}.\n Actual:\n {}\n Expected:\n {}" ,
68
+ fixture_name,
69
69
serde_json:: to_string_pretty( & actual_json) . unwrap( ) ,
70
70
serde_json:: to_string_pretty( & expected_json) . unwrap( ) ) ;
71
71
}
0 commit comments