Skip to content

test: Fix combine_logs.py for AppVeyor build - #16973

Merged
maflcko merged 1 commit into
bitcoin:masterfrom
mzumsande:201909_test_pathsep
Oct 10, 2019
Merged

maflcko merged 1 commit into
bitcoin:masterfrom
mzumsande:201909_test_pathsep

Conversation

@mzumsande

@mzumsande mzumsande commented Sep 26, 2019 •

Copy link
Copy Markdown
Contributor

Fixes #16894

This fixes the problem of AppVeyor builds not showing debug.log if a functional test fails, because the windows separator \ doesn't work together with the regex in combine_logs.py.

A fix was already attempted in #16896, however, that PR became inactive and was marked "up for grabs", plus it's a really small change.

As suggested by jamesob, this PR uses pathlib: For the glob and to convert the path to a posix-style string, it leaves the regex as is (in contrast to #16896 which adjusted the regex).

I tested this locally on Windows and Ubuntu.

Comment thread test/functional/combine_logs.py Resolved

@promag promag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, just a nit suggestion.

Comment thread test/functional/combine_logs.py Resolved
Comment thread test/functional/combine_logs.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit,

glob = pathlib.Path(tmp_dir).glob('node0/**/debug.log')
path = next(glob, None)
if path:
    assert next(glob, None) == None      # should never happen
    chain = ...
    ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, that makes it a bit more readable. Also added assert.

@fjahr fjahr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK
tested on macOS

Comment thread test/functional/combine_logs.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, not critical here but if it should never happen I would throw an exception instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added an assert, as suggested above.

@maflcko

maflcko commented Oct 10, 2019

Copy link
Copy Markdown
Member

Sorry, forgot about this. I thought it was already merged.

maflcko pushed a commit that referenced this pull request Oct 10, 2019
d478a47 test: Fix combine_logs.py for AppVeyor build (Martin Zumsande)

Pull request description:

  Fixes #16894

  This fixes the problem of AppVeyor builds not showing `debug.log` if a functional test fails, because the windows separator `\` doesn't work together with the regex in `combine_logs.py`.

  A fix was already attempted in  #16896, however, that PR became inactive and was marked "up for grabs", plus it's a really small change.

  As suggested by jamesob, this PR uses `pathlib`: For the glob and to convert the path to a posix-style string, it leaves the regex as is (in contrast to #16896 which adjusted the regex).

  I tested this locally on Windows and Ubuntu.

Top commit has no ACKs.

Tree-SHA512: 603b4359b6009b6da874c30f69759acda03730ee5747898a0fe957a5fc37ee9ba07858c6aa2169bf4c40521f37e47138e8314d698652ea2760fa0a3f76b890bd
@maflcko
maflcko merged commit d478a47 into bitcoin:master Oct 10, 2019
if chain:
chain = chain[0] # pick the first one if more than one chain was found (should never happen)
chain = re.search(r'node0/(.+?)/debug\.log$', chain).group(1) # extract the chain name
glob = pathlib.Path(tmp_dir).glob('node0/**/debug.log')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this recursive on purpose or would 'node0/*/debug.log' suffice?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not on purpose. Non-recursive would suffice, I can't imagine a scenario where debug.log ends up in any subdirectories of node0.

@mzumsande
mzumsande deleted the 201909_test_pathsep branch May 10, 2020 21:09
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 28, 2020
Summary:
The regex used to find the chain name in debug.log path did not work on Windows due to the different path separator.
This uses `pathlib` to make sure the path used for the regex search is `as_posix()`

This is a backport of Core [[bitcoin/bitcoin#16973 | PR16973]]

Test Plan:
I tested that it still works on my linux machine, with the same test as D7796

Intentionaly modify a functional test to make it fail (`assert False`), then run:

```
../test/functional/feature_bip68_sequence.py --configfile=./test/config.ini
../test/functional/combine_logs.py -c
```

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D8150
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Feb 1, 2022
d478a47 test: Fix combine_logs.py for AppVeyor build (Martin Zumsande)

Pull request description:

  Fixes bitcoin#16894

  This fixes the problem of AppVeyor builds not showing `debug.log` if a functional test fails, because the windows separator `\` doesn't work together with the regex in `combine_logs.py`.

  A fix was already attempted in  bitcoin#16896, however, that PR became inactive and was marked "up for grabs", plus it's a really small change.

  As suggested by jamesob, this PR uses `pathlib`: For the glob and to convert the path to a posix-style string, it leaves the regex as is (in contrast to bitcoin#16896 which adjusted the regex).

  I tested this locally on Windows and Ubuntu.

Top commit has no ACKs.

Tree-SHA512: 603b4359b6009b6da874c30f69759acda03730ee5747898a0fe957a5fc37ee9ba07858c6aa2169bf4c40521f37e47138e8314d698652ea2760fa0a3f76b890bd
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AppVeyor CI: combine_logs.py fails to fetch debug logs

6 participants