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

Add check_path.py test to verify existing path elements are maintained #658

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
PYTHON_BIN: "C:\\Python27amd64"
PYTHONUNBUFFERED: "1"
EMSDK_NOTTY: "1"
EMSDK_VERBOSE: "1"
steps:
- checkout
- run:
Expand Down
1 change: 1 addition & 0 deletions emsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2496,6 +2496,7 @@ def to_msys_path(p):
# Looks at the current PATH and adds and removes entries so that the PATH reflects
# the set of given active tools.
def adjusted_path(tools_to_activate, system=False, user=False):
debug_print('adjusted_path: system=%s user=%s msys=%s' % (system, user, MSYS))
# These directories should be added to PATH
path_add = get_required_path(tools_to_activate)
# These already exist.
Expand Down
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)
23 changes: 18 additions & 5 deletions scripts/test.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
:: 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

:: first test with --persistent
CALL emsdk activate latest
CALL emsdk_env.bat --persistent
:: Check that no path elements were removed
CALL python scripts/check_path.py "%OLD_PATH%"
CALL python -c "import sys; print(sys.executable)"
CALL emcc.bat -v

:: then test without --persistent
CALL emsdk activate latest
CALL emsdk_env.bat
:: Check that no path elements were removed
CALL python scripts/check_path.py "%OLD_PATH%"
CALL python -c "import sys; print(sys.executable)"
CALL emcc.bat -v
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"