[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/007 f77d9219 05/18: Add two new ledger emiss
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/007 f77d9219 05/18: Add two new ledger emission options |
Date: |
Sun, 24 Apr 2022 18:46:13 -0400 (EDT) |
branch: valyuta/007
commit f77d921932e81818653469af4f37a3d8357d1624
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 af3e40a5..e4db5806 100755
--- a/nychthemeral_test.sh
+++ b/nychthemeral_test.sh
@@ -372,11 +372,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 \
- [lmi-commits] [lmi] valyuta/007 03989383 04/18: Add a new ledger emission option, (continued)
- [lmi-commits] [lmi] valyuta/007 03989383 04/18: Add a new ledger emission option, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 a30da52f 06/18: Test eleven farraginous files nychthemerally, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 d8b0c732 10/18: Record speed measurements, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 8c56b11b 11/18: Improve documentation, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 66592ac8 12/18: Rearrange ledger formats, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 9201d7ef 01/18: Allow "touchstone" files to contain '\t', Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 ba639668 08/18: Reorder format-style map, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 b480490b 13/18: Distinguish two ledger formats, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 9bc66a02 18/18: Revert "Temporarily filter out factor-of-100 errors", Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 e8a5d1a4 17/18: Temporarily filter out factor-of-100 errors, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 f77d9219 05/18: Add two new ledger emission options,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/007 7e2c48ae 03/18: Filter unexpectedly small system-test discrepancies, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 e3830e7a 07/18: Fix omissions earlier on this branch, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 2a247e37 16/18: Mark or expunge unused fields, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 6fa464d3 02/18: Avoid writing " \n", Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 e2f2679c 09/18: Clean up beforehand, not afterward, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 2dfc93c1 14/18: Rearrange ledger formats, Greg Chicares, 2022/04/24
- [lmi-commits] [lmi] valyuta/007 847f3e0f 15/18: Use a more reasonable format for an unused field, Greg Chicares, 2022/04/24