Skip to content

test: replaced hard coded folders with os.path.join & replaced os.path.sep - #16896

Closed
renepickhardt wants to merge 1 commit into
bitcoin:masterfrom
renepickhardt:patch-seperator
Closed

renepickhardt wants to merge 1 commit into
bitcoin:masterfrom
renepickhardt:patch-seperator

Conversation

@renepickhardt

@renepickhardt renepickhardt commented Sep 17, 2019 •

Copy link
Copy Markdown

This should fix the firstGoodIssue #16894 (which I discovered with carldongs firstGoodIssueTwitter bot c.f.: https://twitter.com/GoodFirstIssues/status/1173915080439795714)

have no windows machine here and couldn't test. relying on ci on github.

…p in regex to fix the firstGoodIssue bitcoin#16894 (which I discovered with carldongs firstGoodIssueTwitter bot)
@maflcko

maflcko commented Sep 17, 2019

Copy link
Copy Markdown
Member

Would be nice to leave the whitespace changes for later. It makes it impossible to review the commit that fixes a bug.

@fanquake fanquake added the Tests label Sep 17, 2019
@mzumsande

Copy link
Copy Markdown
Contributor

Thanks for picking this up! If everything succeeds, combine_logs won't be invoked. So for testing, you could add a second commit that makes some functional test trivially fail and after checking the CIs' output remove it again and add a link to the logs here.

@renepickhardt

Copy link
Copy Markdown
Author

Would be nice to leave the whitespace changes for later. It makes it impossible to review the commit that fixes a bug.

sorry my emacs just has some auto save actions to follow the PEP8 formatting. I didn't even realize that that has happened.

What do you (@MarcoFalke ) want me to do? I could quickly mark the 4 relevant lines here on github or do you want me to redo the patch without changes to whitespace?

@renepickhardt renepickhardt left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

actually the whitespace stuff didn't mess it up so badly everything between line 81 and 120 that was changed is actually a change that would have occured even without the whitespace formatting changes. everything above and blow can easily be neglected.

# Find out what the folder is called that holds the debug.log file
chain = glob.glob("{}/node0/*/debug.log".format(tmp_dir))

chain = glob.glob(os.path.join(tmp_dir, "node0", "*", "debug.log"))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

first change

chain = chain[0]
sep = os.path.sep
chain = re.search(r'node0' + sep + '(.+?)' + sep +
'debug\.log$', chain).group(1) # extract the chain name

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

second change

chain = 'regtest'

files = [("test", "%s/test_framework.log" % tmp_dir)]
files = [("test", os.path.join(tmp_dir, "test_framework.log"))]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

third change

files = [("test", os.path.join(tmp_dir, "test_framework.log"))]
for i in itertools.count():
logfile = "{}/node{}/{}/debug.log".format(tmp_dir, i, chain)
logfile = os.path.join(tmp_dir, "node{}".format(i), chain, "debug.log")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fourth change

for stream in ['stdout', 'stderr']:
for i in itertools.count():
folder = "{}/node{}/{}".format(tmp_dir, i, stream)
folder = os.path.join(tmp_dir, "node{}".format(i), stream)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

5th change

for fn in fns:
warning = pathlib.Path('{}/{}'.format(folder, fn)).read_text().strip()
warning = pathlib.Path(os.path.join(
folder, fn)).read_text().strip()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

6th change

@maflcko

maflcko commented Sep 17, 2019

Copy link
Copy Markdown
Member

We don't enforce a maximum line length, and different contributors have different preferences about the line length. Thus, we can't (for now) have editors auto-format a file that was saved. Otherwise, the lines would just ping-pong around on every change. Generally, we leave the line length like it was previously.

@DrahtBot

DrahtBot commented Sep 17, 2019 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #8994 (Testchains: Introduce custom chain whose constructor... by jtimon)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@maflcko

maflcko commented Sep 17, 2019

Copy link
Copy Markdown
Member

Also, I think it would be easier to read the commit message if it was shorter. See https://chris.beams.io/posts/git-commit/

@mzumsande

Copy link
Copy Markdown
Contributor

This doesn't seem to be working yet. I cherry-picked your commit in order to understand why AppVeyor doesn't like my PR #16756 (that's the background why I created #16894), and combine_logs.py still doesn't work: https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/27470906
Also, the linter complains about an invalid escaping sequence. https://travis-ci.org/bitcoin/bitcoin/jobs/586103029

@renepickhardt

Copy link
Copy Markdown
Author

@mzumsande I am a little bit confused about the error. First of all the error message changed which (hopefully means progress) but I cannot make much of the error message as I don't see where unbalanced parenthesis would come from. Also I am somewhat confused that at least in the error message there is still the usage of / and ...

@MarcoFalke once @mzumsande get the code running I will make a force push with the patch withouth outsave actions and with a better commit message

@mzumsande mzumsande 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.

See my post below. Also see my suggestion in post 3, if all functional tests pass, you can't see if your change works, as the current AppVeyor build shows.

# pick the first one if more than one chain was found (should never happen)
chain = chain[0]
sep = os.path.sep
chain = re.search(r'node0' + sep + '(.+?)' + sep +

@mzumsande mzumsande Sep 17, 2019 •

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.

I think the issue is that the windows separator \ needs to be escaped when used in a regex. Not a great expert on regex, but with the following it should work:

if sep == '\\':
            sep = '\\\\'

@laanwj

laanwj commented Sep 18, 2019

Copy link
Copy Markdown
Member

Thanks for contributing. Concept ACK.

I'd also suggest removing the whitespace and formatting changes (at least to lines not touched otherwise) and focusing the changes on the issue that you're trying to fix. This makes reviewing easier, and keeps the git commit log more readable.

@fanquake fanquake changed the title replaced hard coded folders with os.path.join & replaced os.path.sep test: replaced hard coded folders with os.path.join & replaced os.path.sep Sep 18, 2019
@promag

promag commented Sep 18, 2019

Copy link
Copy Markdown
Contributor

Agree with @laanwj, limit the change to the PR scope.

# pick the first one if more than one chain was found (should never happen)
chain = chain[0]
sep = os.path.sep
chain = re.search(r'node0' + sep + '(.+?)' + sep +

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.

Would prefer we just use pathlib here.

@maflcko

maflcko commented Sep 18, 2019

Copy link
Copy Markdown
Member

Yeah, pretty sure this is just a trivial one line fix. No need to blow up the scope of this pull request beside the minimal required fix.

chain = chain[0]
sep = os.path.sep
chain = re.search(r'node0' + sep + '(.+?)' + sep +
'debug\.log$', chain).group(1) # extract the chain name

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: \. is not a valid escape sequence :)

@mzumsande

Copy link
Copy Markdown
Contributor

Since this has gone inactive and marked "up for grabs", I opened #16973.

@maflcko maflcko closed this Sep 26, 2019
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
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.

9 participants