From 0c63b758e378fb129fbc302f6dc22dca58c90846 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Wed, 28 Feb 2018 01:57:44 +0100 Subject: [PATCH] replace individual test with equivalent with custom .args files --- README.md | 2 +- tests/allman/constraint_singe_tab.d.ref | 9 +++ tests/allman/constraint_singe_tab2.d.ref | 10 +++ tests/constraint_singe_tab.args | 2 + tests/constraint_singe_tab.d | 4 ++ tests/constraint_singe_tab2.args | 2 + tests/constraint_singe_tab2.d | 4 ++ tests/individual/README.md | 4 -- tests/individual/single_constraint_indent.d | 73 --------------------- tests/otbs/constraint_singe_tab.d.ref | 7 ++ tests/otbs/constraint_singe_tab2.d.ref | 8 +++ tests/test.sh | 15 ----- 12 files changed, 47 insertions(+), 93 deletions(-) create mode 100644 tests/allman/constraint_singe_tab.d.ref create mode 100644 tests/allman/constraint_singe_tab2.d.ref create mode 100644 tests/constraint_singe_tab.args create mode 100644 tests/constraint_singe_tab.d create mode 100644 tests/constraint_singe_tab2.args create mode 100644 tests/constraint_singe_tab2.d delete mode 100644 tests/individual/README.md delete mode 100644 tests/individual/single_constraint_indent.d create mode 100644 tests/otbs/constraint_singe_tab.d.ref create mode 100644 tests/otbs/constraint_singe_tab2.d.ref diff --git a/README.md b/README.md index 10d5427..b597692 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ dfmt_space_before_function_parameters | `true`, `false` | `false` | Insert space dfmt_selective_import_space | `true`, `false` | `true` | Insert space after the module name and before the `:` for selective imports. dfmt_compact_labeled_statements | `true`, `false` | `true` | Place labels on the same line as the labeled `switch`, `for`, `foreach`, or `while` statement. dfmt_template_constraint_style | `conditional_newline_indent` `conditional_newline` `always_newline` `always_newline_indent` | `conditional_newline_indent` | Control the formatting of template constraints. -dfmt_single_template_constraint_indent | `true`, `false` | `false` | Set if the constraints are indented by a single tab instead of two. Has only an effect for certain indentation styles. +dfmt_single_template_constraint_indent | `true`, `false` | `false` | Set if the constraints are indented by a single tab instead of two. Has only an effect for if indentation style if set to `always_newline_indent` or `conditional_newline_indent`. ## Terminology * Braces - `{` and `}` diff --git a/tests/allman/constraint_singe_tab.d.ref b/tests/allman/constraint_singe_tab.d.ref new file mode 100644 index 0000000..176e0f4 --- /dev/null +++ b/tests/allman/constraint_singe_tab.d.ref @@ -0,0 +1,9 @@ +void foo()() + if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees + && cows && sheeps && monkeys && whales) +{ +} + +void foo()() if (dogs && pigs && birds) +{ +} diff --git a/tests/allman/constraint_singe_tab2.d.ref b/tests/allman/constraint_singe_tab2.d.ref new file mode 100644 index 0000000..59c0cb1 --- /dev/null +++ b/tests/allman/constraint_singe_tab2.d.ref @@ -0,0 +1,10 @@ +void foo()() + if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees + && cows && sheeps && monkeys && whales) +{ +} + +void foo()() + if (dogs && pigs && birds) +{ +} diff --git a/tests/constraint_singe_tab.args b/tests/constraint_singe_tab.args new file mode 100644 index 0000000..2797662 --- /dev/null +++ b/tests/constraint_singe_tab.args @@ -0,0 +1,2 @@ +--template_constraint_style=conditional_newline_indent +--single_template_constraint_indent=true diff --git a/tests/constraint_singe_tab.d b/tests/constraint_singe_tab.d new file mode 100644 index 0000000..097b267 --- /dev/null +++ b/tests/constraint_singe_tab.d @@ -0,0 +1,4 @@ +void foo()() if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees && cows && sheeps && monkeys && whales) +{} + +void foo()() if (dogs && pigs && birds) {} diff --git a/tests/constraint_singe_tab2.args b/tests/constraint_singe_tab2.args new file mode 100644 index 0000000..608415d --- /dev/null +++ b/tests/constraint_singe_tab2.args @@ -0,0 +1,2 @@ +--template_constraint_style=always_newline_indent +--single_template_constraint_indent=true diff --git a/tests/constraint_singe_tab2.d b/tests/constraint_singe_tab2.d new file mode 100644 index 0000000..097b267 --- /dev/null +++ b/tests/constraint_singe_tab2.d @@ -0,0 +1,4 @@ +void foo()() if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees && cows && sheeps && monkeys && whales) +{} + +void foo()() if (dogs && pigs && birds) {} diff --git a/tests/individual/README.md b/tests/individual/README.md deleted file mode 100644 index ec1e6b6..0000000 --- a/tests/individual/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# DFMT individual tests - -Each D source file in this folder gets only compiled and executed with DMD. -Each must contain its own functions to call and test particular features. diff --git a/tests/individual/single_constraint_indent.d b/tests/individual/single_constraint_indent.d deleted file mode 100644 index fc7a8a7..0000000 --- a/tests/individual/single_constraint_indent.d +++ /dev/null @@ -1,73 +0,0 @@ -module single_constraint_indent; - -private string dfmt_name; - -static this() -{ - import std.path : dirName; - dfmt_name = __FILE_FULL_PATH__.dirName ~ "/../../bin/dfmt"; -} - -private immutable input1 = q{ -void foo()() if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees && cows && sheeps && monkeys && whales) -{}}; -private immutable expected1 = q{ -void foo()() - if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees - && cows && sheeps && monkeys && whales) -{ -}}; -private immutable input2 = q{ -void foo()() if (dogs && pigs && birds) -{}}; -private immutable expected21 = q{ -void foo()() if (dogs && pigs && birds) -{ -}}; -private immutable expected22 = q{ -void foo()() - if (dogs && pigs && birds) -{ -}}; - -private void test(string input, string expected, string[] dfmt_args) -{ - import std.array : array, join; - import std.conv : to; - import std.process : ProcessPipes, pipeProcess, wait; - import std.stdio : stderr; - - ProcessPipes pp = pipeProcess(([dfmt_name] ~ dfmt_args)); - pp.stdin.write(input); - pp.stdin.close; - const r = wait(pp.pid); - const e = pp.stderr.byLineCopy.array.join("\n"); - if (r == 0) - { - assert(e.length == 0, "unexpected stderr content: \n" ~ e); - const auto formatted_output = "\n" ~ pp.stdout.byLineCopy.array.join("\n"); - assert(formatted_output == expected, formatted_output); - } - else assert(false, "abnormal dfmt termination : " ~ to!string(r) ~ "\n" ~ e); -} - -void main() -{ - input1.test(expected1, [ - "--template_constraint_style=always_newline_indent", - "--single_template_constraint_indent=true", - ]); - input1.test(expected1, [ - "--template_constraint_style=conditional_newline_indent", - "--single_template_constraint_indent=true", - ]); - input2.test(expected21, [ - "--template_constraint_style=conditional_newline_indent", - "--single_template_constraint_indent=true", - ]); - input2.test(expected22, [ - "--template_constraint_style=always_newline_indent", - "--single_template_constraint_indent=true", - ]); -} - diff --git a/tests/otbs/constraint_singe_tab.d.ref b/tests/otbs/constraint_singe_tab.d.ref new file mode 100644 index 0000000..39fb8eb --- /dev/null +++ b/tests/otbs/constraint_singe_tab.d.ref @@ -0,0 +1,7 @@ +void foo()() + if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees + && cows && sheeps && monkeys && whales) { +} + +void foo()() if (dogs && pigs && birds) { +} diff --git a/tests/otbs/constraint_singe_tab2.d.ref b/tests/otbs/constraint_singe_tab2.d.ref new file mode 100644 index 0000000..975bf28 --- /dev/null +++ b/tests/otbs/constraint_singe_tab2.d.ref @@ -0,0 +1,8 @@ +void foo()() + if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees + && cows && sheeps && monkeys && whales) { +} + +void foo()() + if (dogs && pigs && birds) { +} diff --git a/tests/test.sh b/tests/test.sh index 77d84c8..7f11c5a 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash set -e -# main test suite for braceStyle in allman otbs do for source in *.d @@ -17,17 +16,3 @@ do diff -u "${braceStyle}/${source}.ref" "${braceStyle}/${source}.out" done done - -# individual tests -cd individual -for source in *.d -do - echo "testing indiviual ${source}" - test_name="${source}_test" - $DC ${source} -of${test_name} - if [ -f ${test_name} ]; then - ./${test_name} - rm -f "${test_name}" - echo "tested indiviual ${source}" - fi -done