From fe410fa23971f1684c713ed2b6c5b17019161d7d Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Fri, 7 Aug 2015 19:42:23 +0200 Subject: [PATCH 1/7] [tests] Set timezone for running tests so that the tests run with a consistent environment. --- CMakeLists.txt | 2 ++ test/CMakeLists.txt | 9 ++++++++- test/regress/1057.test | 2 +- test/unit/CMakeLists.txt | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e455ec02..2516b530 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ set(Ledger_VERSION_PATCH 1) set(Ledger_VERSION_PRERELEASE "-alpha.1") set(Ledger_VERSION_DATE 20141005) +set(Ledger_TEST_TIMEZONE "America/Chicago") + # Point CMake at any custom modules we may ship list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0e7d5f2c..d0b62f6e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,6 +25,8 @@ macro(add_ledger_harness_tests _class) COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/RegressTests.py $ ${PROJECT_SOURCE_DIR} ${TestFile} ${TEST_PYTHON_FLAGS}) + set_tests_properties(${_class}Test_${TestFile_Name} + PROPERTIES ENVIRONMENT "TZ=${Ledger_TEST_TIMEZONE}") set_target_properties(check PROPERTIES DEPENDS ${_class}Test_${TestFile_Name}) endif() @@ -44,7 +46,10 @@ if (PYTHONINTERP_FOUND) add_test(NAME ${_class}Test_${TestFile_Name} COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/${_class}.py --ledger $ --file ${TestFile}) - set_target_properties(check PROPERTIES DEPENDS ${_class}Test_${TestFile_Name}) + set_tests_properties(${_class}Test_${TestFile_Name} + PROPERTIES ENVIRONMENT "TZ=${Ledger_TEST_TIMEZONE}") + set_target_properties(check + PROPERTIES DEPENDS ${_class}Test_${TestFile_Name}) endforeach() # CheckManpage and CheckTexinfo are disabled, since they do not work @@ -54,6 +59,8 @@ if (PYTHONINTERP_FOUND) add_test(NAME ${_class} COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/${_class}.py --ledger $ --source ${PROJECT_SOURCE_DIR}) + set_tests_properties(${_class} + PROPERTIES ENVIRONMENT "TZ=${Ledger_TEST_TIMEZONE}") endforeach() endif() diff --git a/test/regress/1057.test b/test/regress/1057.test index 94d82767..1cd91ee7 100644 --- a/test/regress/1057.test +++ b/test/regress/1057.test @@ -4,7 +4,7 @@ * Passif:Crédit:BanqueAccord -171,63 € test -f test/regress/1057.test --now=2014/06/27 emacs -(("$sourcepath/test/regress/1057.test" 1 (21308 34912 0) nil "www.amazon.fr" +(("$sourcepath/test/regress/1057.test" 1 (21308 60112 0) nil "www.amazon.fr" (2 "Dépense:Loisir:Ordi:Matériel" "101,50 €" nil " disque dur portable 2,5\" 2000 Go") (3 "Dépense:Maison:Service:Poste" "70,13 €" nil) (4 "Passif:Crédit:BanqueAccord" "-171,63 €" t))) diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index de7fdd26..4f688755 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -1,6 +1,8 @@ macro(add_ledger_test _name) target_link_libraries(${_name} libledger) add_test(Ledger${_name} ${PROJECT_BINARY_DIR}/${_name}) + set_tests_properties(Ledger${_name} + PROPERTIES ENVIRONMENT "TZ=${Ledger_TEST_TIMEZONE}") endmacro(add_ledger_test _name) include_directories(${PROJECT_SOURCE_DIR}/src) From 64b285d583af1d15475c8164181e215174dfd61d Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sat, 8 Aug 2015 00:55:19 +0200 Subject: [PATCH 2/7] [tests] Fix MathTest failures on Mac OS X due to timezone settings. --- test/unit/t_value.cc | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/test/unit/t_value.cc b/test/unit/t_value.cc index e8367bbe..2daedcb1 100644 --- a/test/unit/t_value.cc +++ b/test/unit/t_value.cc @@ -109,12 +109,11 @@ BOOST_AUTO_TEST_CASE(testEquality) { struct tm localtime; strptime("10 February 2010", "%d %b %Y", &localtime); - time_t time_var = mktime(&localtime); value_t::sequence_t s1; value_t v1; value_t v2(true); - value_t v3(boost::posix_time::from_time_t(time_var)); + value_t v3(boost::posix_time::ptime_from_tm(localtime)); value_t v4(date_t(parse_date("2014/08/14"))); value_t v5(2L); value_t v6(2UL); @@ -131,7 +130,7 @@ BOOST_AUTO_TEST_CASE(testEquality) BOOST_CHECK_EQUAL(v1, value_t()); BOOST_CHECK_EQUAL(v2, value_t(true)); - BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::from_time_t(time_var))); + BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime))); BOOST_CHECK(!(v4 == value_t(date_t(parse_date("2014/08/15"))))); value_t v19(amount_t("2")); @@ -209,12 +208,11 @@ BOOST_AUTO_TEST_CASE(testAddition) { struct tm localtime; strptime("10 February 2010 00:00:00", "%d %b %Y %H:%M:%S", &localtime); - time_t time_var = mktime(&localtime); value_t::sequence_t s1; value_t v1; value_t v2(true); - value_t v3(boost::posix_time::from_time_t(time_var)); + value_t v3(boost::posix_time::ptime_from_tm(localtime)); value_t v4(date_t(parse_date("2014/08/14"))); value_t v5(2L); value_t v6(2UL); @@ -234,12 +232,14 @@ BOOST_AUTO_TEST_CASE(testAddition) v14 += v12; BOOST_CHECK_EQUAL(v14, value_t(string("commentcomment$1.00"), true)); + strptime("10 February 2010 00:00:00", "%d %b %Y %H:%M:%S", &localtime); + BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime))); v3 += value_t(2L); strptime("10 February 2010 00:00:02", "%d %b %Y %H:%M:%S", &localtime); - BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::from_time_t(mktime(&localtime)))); + BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime))); v3 += value_t(amount_t("2")); strptime("10 February 2010 00:00:04", "%d %b %Y %H:%M:%S", &localtime); - BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::from_time_t(mktime(&localtime)))); + BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime))); v4 += value_t(2L); BOOST_CHECK_EQUAL(v4, value_t(date_t(parse_date("2014/08/16")))); @@ -315,12 +315,11 @@ BOOST_AUTO_TEST_CASE(testSubtraction) { struct tm localtime; strptime("10 February 2010 00:00:04", "%d %b %Y %H:%M:%S", &localtime); - time_t time_var = mktime(&localtime); value_t::sequence_t s1; value_t v1; value_t v2(true); - value_t v3(boost::posix_time::from_time_t(time_var)); + value_t v3(boost::posix_time::ptime_from_tm(localtime)); value_t v4(date_t(parse_date("2014/08/18"))); value_t v5(6L); value_t v6(6UL); @@ -337,10 +336,10 @@ BOOST_AUTO_TEST_CASE(testSubtraction) v3 -= value_t(2L); strptime("10 February 2010 00:00:02", "%d %b %Y %H:%M:%S", &localtime); - BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::from_time_t(mktime(&localtime)))); + BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime))); v3 -= value_t(amount_t("2")); strptime("10 February 2010 00:00:00", "%d %b %Y %H:%M:%S", &localtime); - BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::from_time_t(mktime(&localtime)))); + BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime))); v4 -= value_t(2L); BOOST_CHECK_EQUAL(v4, value_t(date_t(parse_date("2014/08/16")))); @@ -419,12 +418,11 @@ BOOST_AUTO_TEST_CASE(testMultiplication) { struct tm localtime; strptime("10 February 2010 00:00:00", "%d %b %Y %H:%M:%S", &localtime); - time_t time_var = mktime(&localtime); value_t::sequence_t s1; value_t v1; value_t v2(true); - value_t v3(boost::posix_time::from_time_t(time_var)); + value_t v3(boost::posix_time::ptime_from_tm(localtime)); value_t v4(date_t(parse_date("2014/08/14"))); value_t v5(2L); value_t v6(2UL); @@ -496,12 +494,11 @@ BOOST_AUTO_TEST_CASE(testDivision) { struct tm localtime; strptime("10 February 2010 00:00:00", "%d %b %Y %H:%M:%S", &localtime); - time_t time_var = mktime(&localtime); value_t::sequence_t s1; value_t v1; value_t v2(true); - value_t v3(boost::posix_time::from_time_t(time_var)); + value_t v3(boost::posix_time::ptime_from_tm(localtime)); value_t v4(date_t(parse_date("2014/08/14"))); value_t v5(8L); value_t v6(2UL); From ee284912a9beb75f7da4127f472de5efb7c6b8bb Mon Sep 17 00:00:00 2001 From: thdox Date: Fri, 24 Apr 2015 18:54:54 +0200 Subject: [PATCH 3/7] Add link to Period expressions. --- doc/ledger3.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 14a71778..5bbb405b 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -3986,8 +3986,8 @@ $ ledger --effective register Groceries @subsection Periodic Transactions @findex --budget -A periodic transaction starts with a @samp{~} followed by a period -expression. Periodic transactions are used for budgeting and +A periodic transaction starts with a tilde @samp{~} followed by a period +expression (see @ref{Period Expressions}). Periodic transactions are used for budgeting and forecasting only, they have no effect without the @option{--budget} option specified. For examples and details, @pxref{Budgeting and Forecasting}. From 7b27eab7db58befa6c7f189b8c9f5015fe3cdd8f Mon Sep 17 00:00:00 2001 From: thdox Date: Fri, 24 Apr 2015 18:59:04 +0200 Subject: [PATCH 4/7] dir- is for directive, feat- for journal feature --- doc/ledger3.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 5bbb405b..ba4932b8 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -10008,9 +10008,9 @@ In case several test files belong to the same bug number the files by appending @anchor{Baseline Test Types} @multitable @columnfractions .3 .7 @headitem Type @tab Use -@item @code{cmd} @tab Ledger commands like @code{register} or @code{balance} -@item @code{dir} @tab ? -@item @code{feat} @tab ? +@item @code{cmd} @tab Ledger commands like @command{register} or @command{balance} +@item @code{dir} @tab Ledger directives like @code{account} or @code{alias} +@item @code{feat} @tab Ledger features such as balance assertions in journal file. @item @code{opt} @tab Ledger options such as @option{--period} or @option{--format} @end multitable From 47070b16ef2e4bf9f60dca1f6312abdfcc881832 Mon Sep 17 00:00:00 2001 From: thdox Date: Sat, 25 Apr 2015 12:13:55 +0200 Subject: [PATCH 5/7] Use @table instead of @multitable In texinfo documentation, @table is for two-columns, @multitable for more. Also, the @table produces nicer PDF output. --- doc/ledger3.texi | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index ba4932b8..362ef4a8 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -10005,14 +10005,18 @@ In case several test files belong to the same bug number the files by appending @code{_X} where @samp{X} is the number of the test, e.g. @samp{1234_1.test}, @samp{1234_2.test}. +Baseline Test Types: @anchor{Baseline Test Types} -@multitable @columnfractions .3 .7 -@headitem Type @tab Use -@item @code{cmd} @tab Ledger commands like @command{register} or @command{balance} -@item @code{dir} @tab Ledger directives like @code{account} or @code{alias} -@item @code{feat} @tab Ledger features such as balance assertions in journal file. -@item @code{opt} @tab Ledger options such as @option{--period} or @option{--format} -@end multitable +@table @code +@item cmd +Ledger commands like @command{register} or @command{balance} +@item dir +Ledger directives like @code{account} or @code{alias} +@item feat +Ledger features such as balance assertions in journal file +@item opt +Ledger options such as @option{--period} or @option{--format} +@end table A ledger test file contains three sections: From b91b74fc43f574719fd21bcd91a4a79ca1cc10be Mon Sep 17 00:00:00 2001 From: thdox Date: Sat, 25 Apr 2015 10:42:17 +0200 Subject: [PATCH 6/7] Rename feat-fixated-prices_2.test to dir-fixed.test For consistency as this is a directive. --- test/baseline/{feat-fixated-prices_2.test => dir-fixed.test} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/baseline/{feat-fixated-prices_2.test => dir-fixed.test} (100%) diff --git a/test/baseline/feat-fixated-prices_2.test b/test/baseline/dir-fixed.test similarity index 100% rename from test/baseline/feat-fixated-prices_2.test rename to test/baseline/dir-fixed.test From 78528810380041a76eec8c87ceef48253581f206 Mon Sep 17 00:00:00 2001 From: thdox Date: Mon, 27 Apr 2015 22:13:53 +0200 Subject: [PATCH 7/7] Improve documentation for .ledgerrc See Github pull request #414 --- doc/ledger3.texi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 362ef4a8..d32d7947 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -5908,7 +5908,9 @@ database. Display the man page for @file{ledger}. @item --init-file @var{FILE} -Specify the location of the init file. The default is @file{~/.ledgerrc}. +Specify the location of the init file. The default is home directory +@file{~/.ledgerrc}, or current directory @file{./.ledgerrc} if not found +in home directory. @item --options Display the options in effect for this Ledger invocation, along with