lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 12192723 06/27: Add two new ledger emission o


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 12192723 06/27: Add two new ledger emission options
Date: Mon, 25 Apr 2022 12:56:14 -0400 (EDT)

branch: master
commit 1219272336019cf07f581111634a994914881bc3
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Add two new ledger emission options
    
    Motivation: to support automated tests of the calculation summary.
    
    Incidentally marked all four (rather than only two) PDF options as
    available only in GUI builds, because all three require wxPdfDoc.
---
 emit_ledger.cpp        | 32 ++++++++++++++++++++++++++++----
 emit_ledger.hpp        |  2 ++
 mc_enum_type_enums.hpp | 32 +++++++++++++++++---------------
 mc_enum_types.cpp      |  6 +++++-
 nychthemeral_test.sh   | 13 ++++++++++---
 5 files changed, 62 insertions(+), 23 deletions(-)

diff --git a/emit_ledger.cpp b/emit_ledger.cpp
index d3e5d986..fa289bbb 100644
--- a/emit_ledger.cpp
+++ b/emit_ledger.cpp
@@ -62,15 +62,23 @@ ledger_emitter::ledger_emitter
 
     if(emission_ & mce_emit_spreadsheet)
         {
-        case_filepath_spreadsheet_  = unique_filepath(f,             tsv_ext);
+        case_filepath_spreadsheet_  = unique_filepath(f,             tsv_ext );
         }
     if(emission_ & mce_emit_group_roster)
         {
-        case_filepath_group_roster_ = unique_filepath(f, ".roster" + tsv_ext);
+        case_filepath_group_roster_ = unique_filepath(f, ".roster" + tsv_ext );
         }
     if(emission_ & mce_emit_group_quote)
         {
-        case_filepath_group_quote_  = unique_filepath(f, ".quote.pdf"       );
+        case_filepath_group_quote_  = unique_filepath(f, ".quote.pdf"        );
+        }
+    if(emission_ & mce_emit_calculation_summary_html)
+        {
+        case_filepath_summary_html_ = unique_filepath(f, ".summary.html"     );
+        }
+    if(emission_ & mce_emit_calculation_summary_tsv)
+        {
+        case_filepath_summary_tsv_  = unique_filepath(f, ".summary" + tsv_ext);
         }
 }
 
@@ -165,6 +173,22 @@ double ledger_emitter::emit_cell
             ;
         custom_io_1_write(ledger, out_file.string());
         }
+    if(emission_ & mce_emit_calculation_summary_html)
+        {
+        fs::ofstream ofs
+            (case_filepath_summary_html_
+            ,ios_out_trunc_binary()
+            );
+        ofs << FormatSelectedValuesAsHtml(ledger);
+        }
+    if(emission_ & mce_emit_calculation_summary_tsv)
+        {
+        fs::ofstream ofs
+            (case_filepath_summary_tsv_
+            ,ios_out_trunc_binary()
+            );
+        ofs << FormatSelectedValuesAsTsv(ledger);
+        }
 
   done:
     return timer.stop().elapsed_seconds();
@@ -194,7 +218,7 @@ double ledger_emitter::finish()
 /// Argument 'cell_filepath' is forwarded to ledger_emitter's ctor,
 /// which interprets it as a "case" rather than a "cell" filepath.
 /// Repurposing it here does no harm, and allows 'emission' to
-/// include mce_emit_spreadsheet.
+/// include other types such as mce_emit_spreadsheet.
 
 double emit_ledger
     (fs::path const& cell_filepath
diff --git a/emit_ledger.hpp b/emit_ledger.hpp
index d2e8a7a7..df2e1ffd 100644
--- a/emit_ledger.hpp
+++ b/emit_ledger.hpp
@@ -59,6 +59,8 @@ class LMI_SO ledger_emitter final
     fs::path case_filepath_spreadsheet_;
     fs::path case_filepath_group_roster_;
     fs::path case_filepath_group_quote_;
+    fs::path case_filepath_summary_html_;
+    fs::path case_filepath_summary_tsv_;
 
     // Used only if emission_ includes mce_emit_group_quote; empty otherwise.
     std::unique_ptr<group_quote_pdf_generator> group_quote_pdf_gen_;
diff --git a/mc_enum_type_enums.hpp b/mc_enum_type_enums.hpp
index ca71e49d..c5acc607 100644
--- a/mc_enum_type_enums.hpp
+++ b/mc_enum_type_enums.hpp
@@ -39,21 +39,23 @@ enum enum_tragic
 /// specified in a single scalar entity.
 
 enum mcenum_emission
-    {mce_emit_nothing        =    0
-    ,mce_emit_composite_only =    1
-    ,mce_emit_quietly        =    2
-    ,mce_emit_to_pwd         =    4
-    ,mce_emit_timings        =    8
-    ,mce_emit_pdf_file       =   16
-    ,mce_emit_pdf_to_printer =   32 // GUI only.
-    ,mce_emit_pdf_to_viewer  =   64 // GUI only.
-    ,mce_emit_test_data      =  128
-    ,mce_emit_spreadsheet    =  256
-    ,mce_emit_group_roster   =  512
-    ,mce_emit_text_stream    = 1024
-    ,mce_emit_custom_0       = 2048
-    ,mce_emit_custom_1       = 4096
-    ,mce_emit_group_quote    = 8192
+    {mce_emit_nothing                  =     0
+    ,mce_emit_composite_only           =     1
+    ,mce_emit_quietly                  =     2
+    ,mce_emit_to_pwd                   =     4
+    ,mce_emit_timings                  =     8
+    ,mce_emit_pdf_file                 =    16 // GUI only.
+    ,mce_emit_pdf_to_printer           =    32 // GUI only.
+    ,mce_emit_pdf_to_viewer            =    64 // GUI only.
+    ,mce_emit_test_data                =   128
+    ,mce_emit_spreadsheet              =   256
+    ,mce_emit_group_roster             =   512
+    ,mce_emit_text_stream              =  1024
+    ,mce_emit_custom_0                 =  2048
+    ,mce_emit_custom_1                 =  4096
+    ,mce_emit_group_quote              =  8192 // GUI only.
+    ,mce_emit_calculation_summary_html = 16384
+    ,mce_emit_calculation_summary_tsv  = 32768
     };
 
 /// Rounding styles.
diff --git a/mc_enum_types.cpp b/mc_enum_types.cpp
index ded2be53..649931da 100644
--- a/mc_enum_types.cpp
+++ b/mc_enum_types.cpp
@@ -68,6 +68,8 @@ extern mcenum_emission const emission_enums[] =
     ,mce_emit_custom_0
     ,mce_emit_custom_1
     ,mce_emit_group_quote
+    ,mce_emit_calculation_summary_html
+    ,mce_emit_calculation_summary_tsv
     };
 extern char const*const emission_strings[] =
     {"emit_nothing"
@@ -85,9 +87,11 @@ extern char const*const emission_strings[] =
     ,"emit_custom_0"
     ,"emit_custom_1"
     ,"emit_group_quote"
+    ,"emit_calculation_summary_html"
+    ,"emit_calculation_summary_tsv"
     };
 template<> struct mc_enum_key<mcenum_emission>
-  :public mc_enum_data<mcenum_emission, 15, emission_enums, emission_strings> 
{};
+  :public mc_enum_data<mcenum_emission, 17, emission_enums, emission_strings> 
{};
 template class mc_enum<mcenum_emission>;
 
 extern rounding_style const rounding_style_enums[] =
diff --git a/nychthemeral_test.sh b/nychthemeral_test.sh
index 919984c1..98fad442 100755
--- a/nychthemeral_test.sh
+++ b/nychthemeral_test.sh
@@ -375,11 +375,18 @@ cd "$throwaway_dir"
 install -m 0664 /opt/lmi/src/lmi/sample.ill .
 install -m 0664 /opt/lmi/src/lmi/sample.cns .
 
-printf '\n# test all valid emission types\n\n'
+printf '\n# test all "emit_*" output types supported by CLI\n\n'
 
-$PERFORM /opt/lmi/bin/lmi_cli_shared --file="$throwaway_dir"/sample.ill 
--accept --ash_nazg --data_path=/opt/lmi/data 
--emit=emit_test_data,emit_spreadsheet,emit_text_stream,emit_custom_0,emit_custom_1
 >/dev/null
+# PDF types not tested: they require wxPdfDoc
 
-$PERFORM /opt/lmi/bin/lmi_cli_shared --file="$throwaway_dir"/sample.cns 
--accept --ash_nazg --data_path=/opt/lmi/data 
--emit=emit_test_data,emit_spreadsheet,emit_group_roster,emit_text_stream,emit_custom_0,emit_custom_1
 >/dev/null
+# 'emit_text_stream' output (on stdout) is tested by 'cli_tests'
+# target above; here, it's discarded (but stderr is not)
+
+# group-roster type omitted: sensible only for a census
+$PERFORM /opt/lmi/bin/lmi_cli_shared --file="$throwaway_dir"/sample.ill 
--accept --ash_nazg --data_path=/opt/lmi/data 
--emit=emit_to_pwd,emit_test_data,emit_spreadsheet,emit_text_stream,emit_custom_0,emit_custom_1,emit_calculation_summary_html,emit_calculation_summary_tsv
 >/dev/null
+
+# calculation-summary types omitted: not sensible for a census
+$PERFORM /opt/lmi/bin/lmi_cli_shared --file="$throwaway_dir"/sample.cns 
--accept --ash_nazg --data_path=/opt/lmi/data 
--emit=emit_to_pwd,emit_test_data,emit_spreadsheet,emit_group_roster,emit_text_stream,emit_custom_0,emit_custom_1
 >/dev/null
 
 printf '\n# schema tests\n\n'
 /opt/lmi/src/lmi/test_schemata.sh 2>&1 \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]