From 9bc33a43f9e98f07ccd56f7ec173782013ad1271 Mon Sep 17 00:00:00 2001 From: Joseph Crail Date: Fri, 5 Jun 2015 19:55:02 -0400 Subject: [PATCH] Fix ptx tests on OS X. For those systems that don't have ptx installed by default, I modified the tests to use pre-calculated results to check against the GNU implementation. --- ...ext_disabled_ignore_and_only_file.expected | 2 ++ .../gnu_ext_disabled_roff_auto_ref.expected | 24 +++++++++++++++++++ .../gnu_ext_disabled_roff_input_ref.expected | 17 +++++++++++++ .../ptx/gnu_ext_disabled_roff_no_ref.expected | 24 +++++++++++++++++++ .../gnu_ext_disabled_tex_auto_ref.expected | 24 +++++++++++++++++++ .../gnu_ext_disabled_tex_input_ref.expected | 17 +++++++++++++ .../ptx/gnu_ext_disabled_tex_no_ref.expected | 24 +++++++++++++++++++ test/ptx.rs | 24 +++++++++---------- 8 files changed, 143 insertions(+), 13 deletions(-) create mode 100644 test/fixtures/ptx/gnu_ext_disabled_ignore_and_only_file.expected create mode 100644 test/fixtures/ptx/gnu_ext_disabled_roff_auto_ref.expected create mode 100644 test/fixtures/ptx/gnu_ext_disabled_roff_input_ref.expected create mode 100644 test/fixtures/ptx/gnu_ext_disabled_roff_no_ref.expected create mode 100644 test/fixtures/ptx/gnu_ext_disabled_tex_auto_ref.expected create mode 100644 test/fixtures/ptx/gnu_ext_disabled_tex_input_ref.expected create mode 100644 test/fixtures/ptx/gnu_ext_disabled_tex_no_ref.expected diff --git a/test/fixtures/ptx/gnu_ext_disabled_ignore_and_only_file.expected b/test/fixtures/ptx/gnu_ext_disabled_ignore_and_only_file.expected new file mode 100644 index 000000000..d57017253 --- /dev/null +++ b/test/fixtures/ptx/gnu_ext_disabled_ignore_and_only_file.expected @@ -0,0 +1,2 @@ +.xx "" """quotes"", for" "roff" "" +.xx "" "{brackets} for" "tex" "" diff --git a/test/fixtures/ptx/gnu_ext_disabled_roff_auto_ref.expected b/test/fixtures/ptx/gnu_ext_disabled_roff_auto_ref.expected new file mode 100644 index 000000000..eefba851b --- /dev/null +++ b/test/fixtures/ptx/gnu_ext_disabled_roff_auto_ref.expected @@ -0,0 +1,24 @@ +.xx "" "" """quotes"", for roff" "" "input:3" +.xx "" "and some other like" "%a, b#, c$c" "" "input:5" +.xx "" "maybe" "also~or^" "" "input:6" +.xx "" "" "and some other like %a, b#, c$c" "" "input:5" +.xx "" "oh," "and back\slash" "" "input:7" +.xx "" "and some other like %a," "b#, c$c" "" "input:5" +.xx "" "oh, and" "back\slash" "" "input:7" +.xx "" "and some other like %a, b#," "c$c" "" "input:5" +.xx "" "let's check special" "characters:" "" "input:2" +.xx "" "let's" "check special characters:" "" "input:2" +.xx "" """quotes""," "for roff" "" "input:3" +.xx "" "{brackets}" "for tex" "" "input:4" +.xx "" "" "hello world!" "" "input:1" +.xx "" "" "let's check special characters:" "" "input:2" +.xx "" "and some other" "like %a, b#, c$c" "" "input:5" +.xx "" "" "maybe also~or^" "" "input:6" +.xx "" "" "oh, and back\slash" "" "input:7" +.xx "" "and some" "other like %a, b#, c$c" "" "input:5" +.xx "" """quotes"", for" "roff" "" "input:3" +.xx "" "and" "some other like %a, b#, c$c" "" "input:5" +.xx "" "let's check" "special characters:" "" "input:2" +.xx "" "{brackets} for" "tex" "" "input:4" +.xx "" "hello" "world!" "" "input:1" +.xx "" "" "{brackets} for tex" "" "input:4" diff --git a/test/fixtures/ptx/gnu_ext_disabled_roff_input_ref.expected b/test/fixtures/ptx/gnu_ext_disabled_roff_input_ref.expected new file mode 100644 index 000000000..f2f3f9160 --- /dev/null +++ b/test/fixtures/ptx/gnu_ext_disabled_roff_input_ref.expected @@ -0,0 +1,17 @@ +.xx "" "some other like" "%a, b#, c$c" "" "and" +.xx "" "" "also~or^" "" "maybe" +.xx "" "" "and back\slash" "" "oh," +.xx "" "some other like %a," "b#, c$c" "" "and" +.xx "" "and" "back\slash" "" "oh," +.xx "" "some other like %a, b#," "c$c" "" "and" +.xx "" "check special" "characters:" "" "let's" +.xx "" "" "check special characters:" "" "let's" +.xx "" "" "for roff" "" """quotes""," +.xx "" "" "for tex" "" "{brackets}" +.xx "" "some other" "like %a, b#, c$c" "" "and" +.xx "" "some" "other like %a, b#, c$c" "" "and" +.xx "" "for" "roff" "" """quotes""," +.xx "" "" "some other like %a, b#, c$c" "" "and" +.xx "" "check" "special characters:" "" "let's" +.xx "" "for" "tex" "" "{brackets}" +.xx "" "" "world!" "" "hello" diff --git a/test/fixtures/ptx/gnu_ext_disabled_roff_no_ref.expected b/test/fixtures/ptx/gnu_ext_disabled_roff_no_ref.expected new file mode 100644 index 000000000..3886e087d --- /dev/null +++ b/test/fixtures/ptx/gnu_ext_disabled_roff_no_ref.expected @@ -0,0 +1,24 @@ +.xx "" "" """quotes"", for roff" "" +.xx "" "and some other like" "%a, b#, c$c" "" +.xx "" "maybe" "also~or^" "" +.xx "" "" "and some other like %a, b#, c$c" "" +.xx "" "oh," "and back\slash" "" +.xx "" "and some other like %a," "b#, c$c" "" +.xx "" "oh, and" "back\slash" "" +.xx "" "and some other like %a, b#," "c$c" "" +.xx "" "let's check special" "characters:" "" +.xx "" "let's" "check special characters:" "" +.xx "" """quotes""," "for roff" "" +.xx "" "{brackets}" "for tex" "" +.xx "" "" "hello world!" "" +.xx "" "" "let's check special characters:" "" +.xx "" "and some other" "like %a, b#, c$c" "" +.xx "" "" "maybe also~or^" "" +.xx "" "" "oh, and back\slash" "" +.xx "" "and some" "other like %a, b#, c$c" "" +.xx "" """quotes"", for" "roff" "" +.xx "" "and" "some other like %a, b#, c$c" "" +.xx "" "let's check" "special characters:" "" +.xx "" "{brackets} for" "tex" "" +.xx "" "hello" "world!" "" +.xx "" "" "{brackets} for tex" "" diff --git a/test/fixtures/ptx/gnu_ext_disabled_tex_auto_ref.expected b/test/fixtures/ptx/gnu_ext_disabled_tex_auto_ref.expected new file mode 100644 index 000000000..f0b0f41c7 --- /dev/null +++ b/test/fixtures/ptx/gnu_ext_disabled_tex_auto_ref.expected @@ -0,0 +1,24 @@ +\xx {}{}{"quotes",}{ for roff}{}{input:3} +\xx {}{and some other like}{\%a,}{ b\#, c\$c}{}{input:5} +\xx {}{maybe}{also~or^}{}{}{input:6} +\xx {}{}{and}{ some other like \%a, b\#, c\$c}{}{input:5} +\xx {}{oh,}{and}{ back\backslash{}slash}{}{input:7} +\xx {}{and some other like \%a,}{b\#,}{ c\$c}{}{input:5} +\xx {}{oh, and}{back\backslash{}slash}{}{}{input:7} +\xx {}{and some other like \%a, b\#,}{c\$c}{}{}{input:5} +\xx {}{let's check special}{characters:}{}{}{input:2} +\xx {}{let's}{check}{ special characters:}{}{input:2} +\xx {}{"quotes",}{for}{ roff}{}{input:3} +\xx {}{$\{$brackets$\}$}{for}{ tex}{}{input:4} +\xx {}{}{hello}{ world!}{}{input:1} +\xx {}{}{let's}{ check special characters:}{}{input:2} +\xx {}{and some other}{like}{ \%a, b\#, c\$c}{}{input:5} +\xx {}{}{maybe}{ also~or^}{}{input:6} +\xx {}{}{oh,}{ and back\backslash{}slash}{}{input:7} +\xx {}{and some}{other}{ like \%a, b\#, c\$c}{}{input:5} +\xx {}{"quotes", for}{roff}{}{}{input:3} +\xx {}{and}{some}{ other like \%a, b\#, c\$c}{}{input:5} +\xx {}{let's check}{special}{ characters:}{}{input:2} +\xx {}{$\{$brackets$\}$ for}{tex}{}{}{input:4} +\xx {}{hello}{world!}{}{}{input:1} +\xx {}{}{$\{$brackets$\}$}{ for tex}{}{input:4} diff --git a/test/fixtures/ptx/gnu_ext_disabled_tex_input_ref.expected b/test/fixtures/ptx/gnu_ext_disabled_tex_input_ref.expected new file mode 100644 index 000000000..8e345339a --- /dev/null +++ b/test/fixtures/ptx/gnu_ext_disabled_tex_input_ref.expected @@ -0,0 +1,17 @@ +\xx {}{some other like}{\%a,}{ b\#, c\$c}{}{and} +\xx {}{}{also~or^}{}{}{maybe} +\xx {}{}{and}{ back\backslash{}slash}{}{oh,} +\xx {}{some other like \%a,}{b\#,}{ c\$c}{}{and} +\xx {}{and}{back\backslash{}slash}{}{}{oh,} +\xx {}{some other like \%a, b\#,}{c\$c}{}{}{and} +\xx {}{check special}{characters:}{}{}{let's} +\xx {}{}{check}{ special characters:}{}{let's} +\xx {}{}{for}{ roff}{}{"quotes",} +\xx {}{}{for}{ tex}{}{$\{$brackets$\}$} +\xx {}{some other}{like}{ \%a, b\#, c\$c}{}{and} +\xx {}{some}{other}{ like \%a, b\#, c\$c}{}{and} +\xx {}{for}{roff}{}{}{"quotes",} +\xx {}{}{some}{ other like \%a, b\#, c\$c}{}{and} +\xx {}{check}{special}{ characters:}{}{let's} +\xx {}{for}{tex}{}{}{$\{$brackets$\}$} +\xx {}{}{world!}{}{}{hello} diff --git a/test/fixtures/ptx/gnu_ext_disabled_tex_no_ref.expected b/test/fixtures/ptx/gnu_ext_disabled_tex_no_ref.expected new file mode 100644 index 000000000..dad32b5f1 --- /dev/null +++ b/test/fixtures/ptx/gnu_ext_disabled_tex_no_ref.expected @@ -0,0 +1,24 @@ +\xx {}{}{"quotes",}{ for roff}{} +\xx {}{and some other like}{\%a,}{ b\#, c\$c}{} +\xx {}{maybe}{also~or^}{}{} +\xx {}{}{and}{ some other like \%a, b\#, c\$c}{} +\xx {}{oh,}{and}{ back\backslash{}slash}{} +\xx {}{and some other like \%a,}{b\#,}{ c\$c}{} +\xx {}{oh, and}{back\backslash{}slash}{}{} +\xx {}{and some other like \%a, b\#,}{c\$c}{}{} +\xx {}{let's check special}{characters:}{}{} +\xx {}{let's}{check}{ special characters:}{} +\xx {}{"quotes",}{for}{ roff}{} +\xx {}{$\{$brackets$\}$}{for}{ tex}{} +\xx {}{}{hello}{ world!}{} +\xx {}{}{let's}{ check special characters:}{} +\xx {}{and some other}{like}{ \%a, b\#, c\$c}{} +\xx {}{}{maybe}{ also~or^}{} +\xx {}{}{oh,}{ and back\backslash{}slash}{} +\xx {}{and some}{other}{ like \%a, b\#, c\$c}{} +\xx {}{"quotes", for}{roff}{}{} +\xx {}{and}{some}{ other like \%a, b\#, c\$c}{} +\xx {}{let's check}{special}{ characters:}{} +\xx {}{$\{$brackets$\}$ for}{tex}{}{} +\xx {}{hello}{world!}{}{} +\xx {}{}{$\{$brackets$\}$}{ for tex}{} diff --git a/test/ptx.rs b/test/ptx.rs index d248a12f9..1c4d4e730 100644 --- a/test/ptx.rs +++ b/test/ptx.rs @@ -10,51 +10,49 @@ mod util; #[test] fn gnu_ext_disabled_roff_no_ref() { let opts = vec!["-G", "-R"]; - test_ptx(&opts); + test_ptx(&opts, "gnu_ext_disabled_roff_no_ref.expected"); } #[test] fn gnu_ext_disabled_roff_input_ref() { let opts = vec!["-G", "-r", "-R"]; - test_ptx(&opts); + test_ptx(&opts, "gnu_ext_disabled_roff_input_ref.expected"); } #[test] fn gnu_ext_disabled_roff_auto_ref() { let opts = vec!["-G", "-A", "-R"]; - test_ptx(&opts); + test_ptx(&opts, "gnu_ext_disabled_roff_auto_ref.expected"); } #[test] fn gnu_ext_disabled_tex_no_ref() { let opts = vec!["-G", "-T", "-R"]; - test_ptx(&opts); + test_ptx(&opts, "gnu_ext_disabled_tex_no_ref.expected"); } #[test] fn gnu_ext_disabled_tex_input_ref() { let opts = vec!["-G", "-T", "-r", "-R"]; - test_ptx(&opts); + test_ptx(&opts, "gnu_ext_disabled_tex_input_ref.expected"); } #[test] fn gnu_ext_disabled_tex_auto_ref() { let opts = vec!["-G", "-T", "-A", "-R"]; - test_ptx(&opts); + test_ptx(&opts, "gnu_ext_disabled_tex_auto_ref.expected"); } #[test] fn gnu_ext_disabled_ignore_and_only_file() { let opts = vec!["-G", "-o", "only", "-i", "ignore"]; - test_ptx(&opts); + test_ptx(&opts, "gnu_ext_disabled_ignore_and_only_file.expected"); } -fn test_ptx(opts: &Vec<&str>) { +fn test_ptx(opts: &Vec<&str>, expected: &str) { let mut ptx = Command::new(PROGNAME); let result = run(&mut ptx.args(opts).arg("input")); - let mut gnu_ptx = Command::new("ptx"); - let gnu_result = run(&mut gnu_ptx.args(opts).arg("input")); - assert_eq!(result.success, true); - assert_eq!(result.stdout, gnu_result.stdout); + assert!(result.success); + assert_eq!(result.stdout, get_file_contents(expected)); assert_empty_stderr!(&result); -} \ No newline at end of file +}