Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14836669 authored by Martin Geisler's avatar Martin Geisler
Browse files

PDL: Fix the order of arguments to ‘assert_eq_with_diff’

We now show the unified diff relative to the known-good code. That is,
if we generate a line too much, this like shows up as an added line.
Before it would show up as a deleted line, which seems wrong.

Test: atest pdl_inline_tests
Change-Id: I9ecb24c4f79b65221131adfe0e44db4529a6a478
parent 2ea11bdb
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -496,7 +496,7 @@ mod tests {
    fn test_generate_preamble() {
        let actual_code = generate_preamble(Path::new("some/path/foo.pdl")).unwrap();
        let expected_code = include_str!("../test/generated/preamble.rs");
        assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
        assert_eq_with_diff(&rustfmt(expected_code), &rustfmt(&actual_code));
    }

    #[test]
@@ -512,7 +512,7 @@ mod tests {
        let decl = &grammar.declarations[0];
        let actual_code = generate_decl(&grammar, &packets, &children, decl).unwrap();
        let expected_code = include_str!("../test/generated/packet_decl_empty.rs");
        assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
        assert_eq_with_diff(&rustfmt(expected_code), &rustfmt(&actual_code));
    }

    #[test]
@@ -532,7 +532,7 @@ mod tests {
        let decl = &grammar.declarations[0];
        let actual_code = generate_decl(&grammar, &packets, &children, decl).unwrap();
        let expected_code = include_str!("../test/generated/packet_decl_simple_little_endian.rs");
        assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
        assert_eq_with_diff(&rustfmt(expected_code), &rustfmt(&actual_code));
    }

    #[test]
@@ -552,6 +552,6 @@ mod tests {
        let decl = &grammar.declarations[0];
        let actual_code = generate_decl(&grammar, &packets, &children, decl).unwrap();
        let expected_code = include_str!("../test/generated/packet_decl_simple_big_endian.rs");
        assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
        assert_eq_with_diff(&rustfmt(expected_code), &rustfmt(&actual_code));
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ pub fn rustfmt(input: &str) -> String {
    String::from_utf8(output.stdout).expect("rustfmt output was not UTF-8")
}

/// Compare two strings using `diff`
/// Find the unified diff between two strings using `diff`.
///
/// # Panics
///