Fix build errors if spaces in path or parent directory #9946

pull pinheadmz wants to merge 1 commits into bitcoin:master from pinheadmz:dirspaces2 changing 2 files +7 −6
  1. pinheadmz commented at 11:20 pm on March 7, 2017: member

    See Issue #9933

    Some work started in PR #5872, but I can’t understand what’s going on in there…

    It fixed the problem I was having (compiling in OSX 10.10.5) if there were spaces anywhere in the absolute path of the source code. Successfully compiled and passed all rpc-tests in paths with and without spaces.

    GNU Make with spaces in filenames seems to be a general issue.

    I will continue to bang on this and see if I break anything else.

  2. fanquake added the label Build system on Mar 8, 2017
  3. laanwj commented at 6:47 am on March 8, 2017: member
    0FileNotFoundError: [Errno 2] No such file or directory: '/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-pc-linux-gnu/qa/rpc-tests/txn_doublespend.py --mineblock'
    

    It’s trying to execute the script + parameter as one executable name.

  4. pinheadmz commented at 7:50 pm on March 8, 2017: member
    Ah yeah some of the tests in the list include –arguments in a string with the command. I wonder why it only failed on Travis builds with python3-zmq? I added two lines that separate the –arguments into list elements so hopefully subprocess.Popen() likes that better on those builds.
  5. laanwj assigned theuni on Mar 9, 2017
  6. theuni commented at 11:14 pm on March 10, 2017: member
    Rather than adding string parsing into the mix here, how about making the tests a pair of [‘filename’, ‘args’] instead?
  7. pinheadmz commented at 9:38 pm on March 13, 2017: member
    I had to change a few other lines to work with the new format [‘filename’, ‘args’] but it’s working for me
  8. MarcoFalke commented at 11:23 pm on March 13, 2017: member
  9. pinheadmz commented at 11:24 pm on March 13, 2017: member
    @MarcoFalke I will, I just want to make sure I was taking @theuni direction correctly on this last modification
  10. fanquake commented at 11:06 pm on March 22, 2017: member
    ping @pinheadmz . This needs a rebase & commits squashed.
  11. pinheadmz commented at 11:15 pm on March 22, 2017: member
    @fanquake happy to do that now but I was hoping to get feedback from @theuni on latest commit: reformat all the test names to lists? Or parse as strings? (Previous commit)
  12. MarcoFalke commented at 11:11 am on March 23, 2017: member
    I think it is fine to have each functional test in the format [‘file_name.py’, ‘arg’] …
  13. pinheadmz force-pushed on Mar 23, 2017
  14. pinheadmz force-pushed on Mar 23, 2017
  15. pinheadmz commented at 5:23 pm on March 23, 2017: member
    wow I really fucked up this rebase, sorry, trying again
  16. pinheadmz force-pushed on Mar 23, 2017
  17. pinheadmz commented at 5:55 pm on March 23, 2017: member
    ok there we go, going to test building in my own directory with spaces to double-check
  18. theuni commented at 5:38 pm on March 24, 2017: member
    @pinheadmz yes, that’s what I had in mind, thanks.
  19. in test/functional/test_runner.py:209 in 51e7a9e59b outdated
    205@@ -205,7 +206,7 @@ def main():
    206     if args.help:
    207         # Print help for test_runner.py, then print help of the first script and exit.
    208         parser.print_help()
    209-        subprocess.check_call((config["environment"]["SRCDIR"] + '/test/functional/' + test_list[0]).split() + ['-h'])
    210+        subprocess.check_call([config["environment"]["SRCDIR"] + '/qa/rpc-tests/' + test_list[0][0]] + ['-h'])
    


    theuni commented at 5:39 pm on March 24, 2017:
    rebase issue

    pinheadmz commented at 5:49 pm on March 24, 2017:
    fixed. sorry/thanks. I guess there’s no test to fail for requesting help!
  20. in test/functional/test_runner.py:252 in 51e7a9e59b outdated
    248@@ -248,6 +249,7 @@ def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=Fal
    249     results = BOLD[1] + "%s | %s | %s\n\n" % ("TEST".ljust(max_len_name), "PASSED", "DURATION") + BOLD[0]
    250     for _ in range(len(test_list)):
    251         (name, stdout, stderr, passed, duration) = job_queue.get_next()
    252+        name = " ".join(name)
    


    theuni commented at 5:44 pm on March 24, 2017:
    What changed here?

    pinheadmz commented at 5:46 pm on March 24, 2017:
    At this point, name is a list not a string. So this turns ['testname', '--arg'] back into 'testname --arg' before it is displayed

    theuni commented at 6:02 pm on March 24, 2017:

    Ah, of course.

    Mind keeping them separate so that’s more obvious? e.g. rename to test and print test[0] + test[1:] ?

  21. pinheadmz force-pushed on Mar 24, 2017
  22. jnewbery commented at 6:48 pm on March 24, 2017: member

    Sorry I’m late to this party. @theuni asked me to take a look at this.

    I really don’t like the approach of changing the list of tests into a list of lists. It’s torturing the test_runner code for the sake of a couple of test cases which take arguments. It’s also borked the formatting of the printout report (look at how max_len_name gets set to see how).

    I think it’s much better (and less intrusive) to keep the test list as a list of strings, and then just change the Popen() call to be something like:

    0test_argv = t.split()
    1self.jobs.append((t,
    2	      time.time(),
    3	      subprocess.Popen([self.tests_dir + test_argv[0]] + test_argv[1:] + self.flags + port_seed,
    4			       universal_newlines=True,
    5			       stdout=log_stdout,
    6			       stderr=log_stderr),
    7	      log_stdout,
    8	      log_stderr))
    

    This is very similar to what Popen() was calling before, it’s just that split() is only being called on the test name string, rather than the complete path. I think that fixes your original problem of test cases not working when there’s a space in the path.

    Can you test that and see if it works for you?

    EDIT: you’ll also need to do the same thing in the subprocess.check_call() call where it’s printing the help text, since that has the same bug (it’s calling split() on the filename with path instead of just the test string)

  23. theuni commented at 7:04 pm on March 24, 2017: member
    @jnewbery That’s pretty much what @pinheadmz’s original approach did, but it led to a good bit of string hacking. @pinheadmz Do you still have your original commits around by chance, for comparison?
  24. pinheadmz commented at 7:07 pm on March 24, 2017: member
    Let me check my backup drive… ;-) I got all these messages to squash! Should’ve trusted my gut. Wouldn’t be hard to re-write anyway and @jnewbery’s suggested code is cleaner anyway.
  25. pinheadmz commented at 7:20 pm on March 24, 2017: member
    Found a backup! https://github.com/bitcoin/bitcoin/pull/9946/commits/33894380c0b0a2ed2f46997c685e75125badd205 is how it was before, with test names as strings and using string parsing instead of lists.
  26. jnewbery commented at 7:22 pm on March 24, 2017: member
    Looks like https://github.com/bitcoin/bitcoin/pull/9946/commits/33894380c0b0a2ed2f46997c685e75125badd205 is the current tip. Do you still have the old commit? Can you push to a new branch on github?
  27. jnewbery commented at 7:29 pm on March 24, 2017: member

    I like https://github.com/bitcoin/bitcoin/pull/9946/commits/16008c4d8dfd1539cefd98feb45d83e6389efd27 much better. My comment would be that rather than what you’re doing:

    • concatenate the base path with the test string
    • then split on " –"

    instead you should:

    • split the test string on whitespace (this is the default for string.split())
    • concatenate the base path with the first entry in the list
    • add that concatenated value with the rest of the list

    That seems reasonable. You’re splitting the test string into arguments based on whitespace (which is what a shell does anyway!)

  28. pinheadmz commented at 11:24 pm on March 24, 2017: member
    This seems to work fine on my computer, installing and testing into directory “bitcoin dev”. Although I do get a lot of timeout errors from some of the tests… any advice on that?
  29. theuni commented at 11:41 pm on March 24, 2017: member
    @pinheadmz Thanks for sticking with this, and sorry for the back and forth. @jnewbery has been doing tons of work on these tests lately, so I’ll defer to his preference.
  30. jnewbery commented at 0:18 am on March 25, 2017: member

    Glad it works. I’ll happily review this once you’ve pushed the new commit.

    Regarding the timeouts: the first thing I’d check is whether there are any bitcoin processes running. Sometimes the framework fails to clean up old processes if the test fails, which can lead to issues next time you run a test. If that’s not the issue, I’ve beefed up the test logs recently. You should be able to run combine_logs.py <test directory> -c | less -r to get a combined view of what happened in the test.

    And if that doesn’t help, please open a new issue with the logs and @ me and I’ll take a look.

  31. pinheadmz force-pushed on Mar 25, 2017
  32. pinheadmz commented at 0:22 am on March 25, 2017: member
    squashed! 1de311d64d477fa2a220aa77840f86f4deabebb6
  33. jnewbery commented at 0:37 am on March 25, 2017: member
  34. fix build if spaces in src dir path b1f584dbc1
  35. pinheadmz force-pushed on Mar 25, 2017
  36. theuni commented at 3:43 am on March 25, 2017: member
    utACK b1f584dbc185fc9961d4d8d16680ca4041f3d1f3
  37. laanwj merged this on Mar 25, 2017
  38. laanwj closed this on Mar 25, 2017

  39. laanwj referenced this in commit 90dd9e6c4c on Mar 25, 2017
  40. PastaPastaPasta referenced this in commit 1caede22a5 on Mar 14, 2019
  41. PastaPastaPasta referenced this in commit ebb16cd994 on May 20, 2019
  42. PastaPastaPasta referenced this in commit 3793129315 on May 21, 2019
  43. PastaPastaPasta referenced this in commit e2efc21fe0 on May 21, 2019
  44. barrystyle referenced this in commit e656e873db on Jan 22, 2020
  45. DrahtBot 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: 2024-12-04 18:12 UTC

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