Skip to content

Commit de74f54

Browse files
authored
Merge pull request #4684 from simpkins/fix_tests
Fix running individual test files when ninja is not installed
2 parents a6abb0f + 38386df commit de74f54

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

testing/framework/TestSCons.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,17 @@
107107
dll_ = dll_prefix
108108

109109
try:
110+
# Note: if the ninja python package is not installed, this import statement can end
111+
# up finding the scons/test/ninja directory instead, and successfully importing
112+
# that directory as an implicit namespace package. Therefore if ninja is
113+
# unavailable, we may not get an ImportError here, but can instead get an
114+
# AttributeError when attempting to access ninja.BIN_DIR below. This happens
115+
# when running individual test files in the test/ directory, since the test/
116+
# directory will then be listed as the first entry in sys.path
110117
import ninja
111118

112119
NINJA_BINARY = os.path.abspath(os.path.join(ninja.BIN_DIR, 'ninja' + _exe))
113-
except ImportError:
120+
except (ImportError, AttributeError):
114121
NINJA_BINARY = None
115122

116123
if sys.platform == 'cygwin':

0 commit comments

Comments
 (0)