Skip to content

Commit

Permalink
fix: appmap breaks python extension repl
Browse files Browse the repository at this point in the history
  • Loading branch information
zermelo-wisen committed Jun 19, 2024
1 parent 1d5a072 commit fa29e91
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ dist: jammy
language: python
python:
- "3.12"
- "3.11"
- "3.10"
- "3.9.14"
- "3.8"

# https://github.com/travis-ci/travis-ci/issues/1147#issuecomment-441393807
if: type != push OR branch = master OR branch =~ /^v\d+\.\d+(\.\d+)?(-\S*)?$/
Expand Down
15 changes: 15 additions & 0 deletions _appmap/test/test_env.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from _appmap.env import Env


Expand All @@ -11,3 +12,17 @@ def test_disable_temporarily():
except RuntimeError:
...
assert env.enables("requests")

def test_determine_log_file(monkeypatch):
env = Env({"_APPMAP": "true"})

def mock_open(*args, **kwargs):
raise IOError("Testing exception")
monkeypatch.setattr("builtins.open", mock_open)

log_file = env.determine_log_file()
# It should be in a temp folder
assert log_file != "appmap.log"
user_home_dir = os.path.expanduser("~")
assert log_file != os.path.join(user_home_dir, "appmap.log")

37 changes: 37 additions & 0 deletions ci/smoketest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,41 @@ EOF
fi
}

test_log_file_not_writable()
{
touch appmap.log
chmod 400 appmap.log

cat <<EOF > test_log_file_not_writable.py
import appmap
from appmap import Recording
with Recording():
print("Hello from appmap library client")
EOF

python test_log_file_not_writable.py

# Check existence and permissions of 'appmap.log'
if [ -e appmap.log ]; then
echo "'appmap.log' exists."
if [ -w appmap.log ]; then
echo "'appmap.log' is writable."
else
echo "'appmap.log' is not writable."
fi
else
echo "'appmap.log' does not exist."
fi

if [[ $? -eq 0 ]]; then
echo 'Script executed successfully'
else
echo 'Script execution failed'
exit 1
fi
}

set -ex
pip -q install -U pip pytest "flask>=2,<3" python-decouple
pip -q install /dist/appmap-*-py3-none-any.whl
Expand All @@ -33,6 +68,8 @@ test_recording_when_appmap_not_true

export APPMAP=true

test_log_file_not_writable

python -m appmap.command.appmap_agent_init |\
python -c 'import json,sys; print(json.load(sys.stdin)["configuration"]["contents"])' > /tmp/appmap.yml
cat /tmp/appmap.yml
Expand Down

0 comments on commit fa29e91

Please sign in to comment.