Skip to content

Commit

Permalink
Add check_path.py test to verify existing path elements are maintained
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Nov 26, 2020
1 parent aa5fedf commit e6d3458
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
34 changes: 34 additions & 0 deletions scripts/check_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
# Given a previous path check that the current path
# contains all the same elements in the same order
# with no elements removed.

import os
import sys


old_path = sys.argv[1].split(os.pathsep)
new_path = os.environ['PATH'].split(os.pathsep)

paths_added = [p for p in new_path if p not in old_path]
paths_preserved = [p for p in new_path if p in old_path]

print('verifying path elemnts have been preserved')
print('old: %s' % old_path)
print('new: %s' % new_path)

for p in old_path:
if p not in paths_preserved:
print('path not reserved: ' + p)
sys.exit(1)

# Check that ordering matches too.
if old_path != paths_preserved:
print('preserved paths don\'t match original path:')
print('old:')
for p in old_path:
print(' - ' + p)
print('preserved:')
for p in paths_preserved:
print(' - ' + p)
sys.exit(1)
13 changes: 8 additions & 5 deletions scripts/test.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
:: equivilent of test.sh as windows bat file
set PATH=%PATH%;%PYTHON_BIN%
@CALL emsdk install latest
@CALL emsdk activate latest
@CALL emsdk_env.bat --build=Release
@CALL python -c "import sys; print(sys.executable)"
@CALL emcc.bat -v
set OLD_PATH=%PATH%
CALL emsdk install latest
CALL emsdk activate latest
CALL emsdk_env.bat --build=Release
CALL python -c "import sys; print(sys.executable)"
CALL emcc.bat -v
:: Check that no path elements were removed
CALL python scripts/check_path.py "%OLD_PATH%"
3 changes: 3 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ echo "test the standard workflow (as close as possible to how a user would do it
set -x
set -e

OLD_PATH=$PATH
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh --build=Release
# On mac and windows python3 should be in the path and point to the
# bundled version.
which python3
emcc -v
# Check that no path elements were removed
python3 scripts/check_path.py "$OLD_PATH"

0 comments on commit e6d3458

Please sign in to comment.