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

bug: don't match archive with glob #23

Merged
merged 1 commit into from
Jun 22, 2024
Merged
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
2 changes: 1 addition & 1 deletion gptscript/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def install():

# Find the extracted binary and rename/move it to the versioned name in the python bin directory
extracted_binary_path = next(
output_dir.glob(gptscript_binary_name + "*"), None
output_dir.glob(gptscript_binary_name), None
) # Adjust the glob pattern if necessary
if extracted_binary_path:
shutil.move(str(extracted_binary_path), str(versioned_binary_path))
Expand Down
16 changes: 13 additions & 3 deletions tests/test_gptscript.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import os
import platform
import subprocess

import pytest

from gptscript.confirm import AuthResponse
from gptscript.frame import RunEventType, CallFrame, RunFrame, RunState, PromptFrame
from gptscript.gptscript import GPTScript
from gptscript.install import install, gptscript_binary_name, python_bin_dir
from gptscript.opts import GlobalOptions, Options
from gptscript.prompt import PromptResponse
from gptscript.run import Run
Expand Down Expand Up @@ -77,6 +79,13 @@ def tool_list():
]


def test_install():
install()
bin_name = str(python_bin_dir / gptscript_binary_name)
process = subprocess.Popen([bin_name, '-v'], stdout=subprocess.PIPE, text=True)
assert process.stdout.read().startswith('gptscript version ')


@pytest.mark.asyncio
async def test_create_another_gptscript():
g = GPTScript()
Expand Down Expand Up @@ -420,15 +429,16 @@ async def process_event(r: Run, frame: CallFrame | RunFrame | PromptFrame):
for output in frame.output:
event_content += output.content

tool = ToolDef(tools=["sys.exec"], instructions="List the files in the current directory.")
tool = ToolDef(tools=["sys.exec"], instructions="List the files in the current directory. If that doesn't work"
"print the word FAIL.")
out = await gptscript.evaluate(tool,
Options(confirm=True, disableCache=True),
event_handlers=[process_event],
).text()

assert confirm_event_found, "No confirm event"
assert "authorization error" in out, "Unexpected output: " + out
assert "authorization error" in event_content, "Unexpected event output: " + event_content
assert "FAIL" in out, "Unexpected output: " + out
assert "FAIL" in event_content, "Unexpected event output: " + event_content


@pytest.mark.asyncio
Expand Down