From 2bc5926b78f637d2b9097de800f76f8a2ddb1626 Mon Sep 17 00:00:00 2001 From: Emmanuel Briot Date: Fri, 7 Feb 2014 15:54:00 +0100 Subject: [PATCH] Display multi-line arguments when displaying steps --- docs/features.rst | 2 +- src/bdd-formatters.adb | 33 ++++++++++++++++++++++++++++++--- src/bdd-parser.adb | 2 +- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/docs/features.rst b/docs/features.rst index e760a25..88cec96 100644 --- a/docs/features.rst +++ b/docs/features.rst @@ -65,7 +65,7 @@ with the first general layout for a file:: There could be several **scenarios** within the **feature**. In fact, there could also be several features in a given file, but this is not recommended in -general. +general (this is an extension of the format used by cucumber). The scenario is split into several **steps**, each of which start on a separate line. The steps are introduced by one of severaal keywords, all shown in bold diff --git a/src/bdd-formatters.adb b/src/bdd-formatters.adb index a2a8b5d..1e17ebe 100644 --- a/src/bdd-formatters.adb +++ b/src/bdd-formatters.adb @@ -261,9 +261,6 @@ package body BDD.Formatters is Put_And_Align (Scenario, Step_Indent & Step.Text); if Self.Term.Has_Colors then - Self.Term.Set_Color - (Term => Ada.Text_IO.Standard_Output, - Style => Reset_All); Display_Location (Self, Scenario, Step); else case Step.Status is @@ -277,6 +274,36 @@ package body BDD.Formatters is Display_Location (Self, Scenario, Step, "[SKIPPED] "); end case; end if; + + declare + Multi : constant String := Step.Multiline; + Start, Last : Integer; + begin + if Multi /= "" then + Self.Term.Set_Color + (Term => Ada.Text_IO.Standard_Output, + Foreground => BDD.Step_Colors (Step.Status)); + Put_Line (" """""""); + + Start := Multi'First; + while Start <= Multi'Last loop + Last := Line_End (Multi, Start); + if Last < Start then -- empty line + New_Line; + Start := Last + 2; + else + Put (" " & Multi (Start .. Last)); + Start := Last + 1; + end if; + end loop; + + Put_Line (" """""""); + end if; + end; + + Self.Term.Set_Color + (Term => Ada.Text_IO.Standard_Output, + Style => Reset_All); end Display_Step; ---------------------------- diff --git a/src/bdd-parser.adb b/src/bdd-parser.adb index 60e5d16..2964604 100644 --- a/src/bdd-parser.adb +++ b/src/bdd-parser.adb @@ -137,7 +137,7 @@ package body BDD.Parser is State := In_Scenario; elsif Step /= null then State := In_String; - String_Indent := First_Char - Line_S; + String_Indent := First_Char - Line_S + 1; String_Line_Start := Line; else raise Syntax_Error with "Multi-line strings only allowed in"