Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#3336] do not add not-found tool paths #3337

Merged
merged 7 commits into from
Apr 24, 2019
Merged

Conversation

mwichmann
Copy link
Collaborator

@mwichmann mwichmann commented Mar 28, 2019

Resolve Issue #3336

When tool modules initialize, they check paths to decide if the underlying tool is actually present. The current checker adds any "default paths" the caller may have supplied (locations like mingw, cygwin, chocolatey install locations, etc.); if there is match from this list, any previous default paths are also kept. To avoid keeping these non-matching paths, restore the original PATH; the caller is responsible for adding to PATH if necessary. Docstring now says so.

Note lex and yacc tool modules expected the path-modifying behavior that's being gotten rid of - so they preseve the path first and restore it after. That has been rolled back out.

The swig.py change is not functional, it just aligns the usage with what is introduced elsewhere.

Signed-off-by: Mats Wichmann [email protected]

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated master/src/CHANGES.txt directory (and read the README.txt in that directory)
  • I have updated the appropriate documentation

@mwichmann
Copy link
Collaborator Author

The one Appveyor fail is from a file close issue for which a patch exists elsewhere, not sure why it's intermittent.

Failed the following test:
	test\Interactive\configure.py
193/300 (64.33%) C:\\Python37\\python.exe test\Interactive\configure.py
FAILED test of C:\projects\scons\src\script\scons.py
	at line 615 of C:\projects\scons\testing\framework\TestCommon.py (_complete)
	from line 675 of C:\projects\scons\testing\framework\TestCommon.py (finish)
	from line 119 of test\Interactive\configure.py
match_re: mismatch at line 2:
  search re='^scons>>> scons: `foo.obj' is up to date.$'
  line='scons>>> C:\Python37\python.exe mycc.py foo.obj foo.cpp'
STDOUT =========================================================================
1,2c1,3

mwichmann added a commit to mwichmann/scons that referenced this pull request Apr 13, 2019
Remove now unneeded code to save/restore the path, since
the routine now does not modify the path.

Signed-off-by: Mats Wichmann <[email protected]>
When tool modules initialize, they check paths to decide if
the underlying tool is actually present.  The current checker adds
any "default paths" the caller may have supplied (locations like
mingw, cygwin, chocolatey install locations, etc.); if there is
match from this list, any previous default paths are also kept.
To avoid keeping these non-matching paths, restore the original PATH;
the caller is responsible for adding to PATH if necessary.
Docstring now says so.

Note lex and yacc tool modules seem to expect the path-modifying
behavior that's being gotten rid of - so they preseve the path
first and restore it after.  The change here won't break those,
but makes the extra behavior unneeded - could remove it.

Signed-off-by: Mats Wichmann <[email protected]>
Remove now unneeded code to save/restore the path, since
the routine now does not modify the path.

Signed-off-by: Mats Wichmann <[email protected]>
"""
# save existing path to reset if we don't want to append any paths
envPath = env['ENV']['PATH']
bins = ['bison', 'yacc', 'win_bison']
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move this list to the top, name win_bins and have a non-win bins and then use that everywhere instead of having several lists scattered throughout the module?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no problem, I've got that ready to push... but while I'm at it, the block in yacc.py from lines 145-151 seems like it is redundant now - like the "old version" was still left around when the get_yacc_path function was added. Should this be dropped?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure.

A list of possible executable names are provided in several places
in yacc and lex tools, make it a little cleaner by defining once,
at the top.

Signed-off-by: Mats Wichmann <[email protected]>
@mwichmann
Copy link
Collaborator Author

fwiw, the build fail from appveyor is surpious - something happend during the chocolatey setup, it wasn't from the tests themselves.

@mwichmann
Copy link
Collaborator Author

So if this test is "wrong", I don't have any other ideas how to test. I don't get how to check a filesystem glob to match jdks without having something in the filesystem to glob against. Maybe just give up on the test?

@bdbaddog
Copy link
Contributor

Unit test's don't touch the filesystem, or shell out and run commands.
I think you should be able to monkey patch glob.. lemme fork your branch and give it a try.
Since the change is really about finding specific directory patterns.
That should be unit testable.. (I think..)

bdbaddog and others added 2 commits April 23, 2019 13:11
Add a unit test to show find_program_path does not alter env['ENV']['PATH'].

A little cleanup in Tool/__init__.py: don't use mutable object as default
value in function signature (checkers complain about this); getter/setter
usage seemed unnecessary - kept one of the two but use modern syntax
(checkers complain about use-before set, which is fixed by the change)

Signed-off-by: Mats Wichmann <[email protected]>
@@ -394,7 +396,8 @@ def _call_env_subst(env, string, *args, **kw):


class _ShLibInfoSupport(object):
def get_libtype(self):
@property
def libtype(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this related to the bug?

@bdbaddog bdbaddog merged commit d642ba8 into SCons:master Apr 24, 2019
@mwichmann mwichmann deleted the tool-add branch April 24, 2019 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants