Test ReadConfigFile #12812

pull Empact wants to merge 1 commits into bitcoin:master from Empact:test-read-config-file changing 3 files +56 −1
  1. Empact commented at 10:15 am on March 28, 2018: member
    I stared writing this for #12765, pulling it out here for easier review.
  2. fanquake added the label Tests on Mar 28, 2018
  3. Empact force-pushed on Mar 28, 2018
  4. jnewbery commented at 3:37 pm on March 29, 2018: member

    unit tests failing in travis:

    0test/getarg_tests.cpp(39): error in "configfile": check gArgs.GetBoolArg("-foo", false) failed
    1test/getarg_tests.cpp(43): error in "configfile": check !gArgs.GetBoolArg("-bar", true) failed
    2test/getarg_tests.cpp(46): error in "configfile": check gArgs.GetArg("-baz", "") == "11" failed [ != 11]
    3test/getarg_tests.cpp(47): error in "configfile": check gArgs.GetArg("-baz", "eleven") == "11" failed [eleven != 11]
    4test/getarg_tests.cpp(49): error in "configfile": check gArgs.GetArg("-qux", "") == "eleven" failed [ != eleven]
    5test/getarg_tests.cpp(53): error in "configfile": check gArgs.GetArg("-baz", 0) == 11 failed [0 != 11]
    6test/getarg_tests.cpp(54): error in "configfile": check gArgs.GetArg("-qux", 11) == 0 failed [11 != 0]
    7test/getarg_tests.cpp(58): error in "configfile": check !gArgs.GetBoolArg("-quux", true) failed
    8test/getarg_tests.cpp(70): error in "configfile": exception std::runtime_error is expected
    
  5. Empact force-pushed on Mar 29, 2018
  6. Empact force-pushed on Mar 29, 2018
  7. Empact force-pushed on Mar 29, 2018
  8. Empact commented at 0:58 am on March 30, 2018: member

    @jnewbery Seems like it was a datadir caching issue, clearing the cache worked.

    Ironically, ParseParameters(’-datadir’) does not clear the datadir cache, probably because ParseParameters is called once and at the beginning of the run.

  9. Test ReadConfigFile 3ea6a91f16
  10. Empact commented at 1:00 am on March 30, 2018: member
    Rerunning after rebase for good measure.
  11. Empact force-pushed on Mar 30, 2018
  12. conscott commented at 2:19 pm on March 30, 2018: contributor
    Tested ACK 3ea6a91f16c076e2774700c0364dfc1e7aca5b2a
  13. in src/test/getarg_tests.cpp:35 in 3ea6a91f16
    29@@ -30,6 +30,50 @@ static void ResetArgs(const std::string& strArg)
    30     gArgs.ParseParameters(vecChar.size(), vecChar.data());
    31 }
    32 
    33+BOOST_AUTO_TEST_CASE(configfile)
    34+{
    35+  fs::path expectedConfigPath(fs::system_complete("test/data/bitcoin.conf"));
    


    laanwj commented at 11:25 am on April 2, 2018:
    The practice for the unit tests has been to embed all test files in the source code - by including the generated test files (in this case bitcoin.conf.raw.h, I think). The reason is that it should be possible to copy test_bitcoin to a new platform (for example by installing the distributed binaries) and run it without copying the entire source tree. If you really need a file (for testing) instead of data in memory, create the file in a temporary directory.
  14. jnewbery commented at 1:52 pm on April 2, 2018: member
    Concept ACK, but agree with @laanwj about the test file. Take a look at https://github.com/bitcoin/bitcoin/blob/821980c00feef143a6ecf6af65926e18cfd30396/src/Makefile.test.include#L161 to see how the .json.h files are generated.
  15. ryanofsky commented at 3:37 pm on April 3, 2018: member

    Take a look at bitcoin/src/Makefile.test.include

    Feel free to fix this whatever way is simplest, but I would probably chose to avoid dealing with make, and instead just put the config in a multiline raw R"(...)" string that maybe gets written to a temporary file at runtime, if necessary.

  16. laanwj commented at 4:50 pm on April 3, 2018: member

    instead just put the config in a multiline raw R"(…)" string that maybe gets written to a temporary file at runtime, if necessary.

    What, C++11 has multi-line string literals? TIL

  17. ajtowns commented at 0:19 am on April 5, 2018: member
    I think #12878 covers most of this (without needing the separate file, due to splitting ReadConfigStream out of ReadConfigFile), and that the -datadir and file-reading testing is probably better done via the functional test suite rather than the unit tests.
  18. Empact commented at 1:32 am on April 5, 2018: member
    Agreed, I prefer #12878 👍
  19. Empact closed this on Apr 5, 2018

  20. Empact deleted the branch on May 30, 2018
  21. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-08-13 12:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me