Skip to content

Commit

Permalink
35: restructured e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufcanb committed Feb 9, 2025
1 parent c157a58 commit daec901
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
run: pip install -r e2e/requirements.txt

- name: Run Tests wo/ Ollama
run: robot --outputdir dist --name tlm --exclude requires=ollama tlm.robot
run: robot --outputdir dist --name tlm --include no-ollama tests/
working-directory: e2e/

- name: Archive e2e artifacts
Expand Down
91 changes: 91 additions & 0 deletions e2e/tests/ask.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
*** Settings ***
Library Collections
Library OperatingSystem
Resource ../tlm.resource

Suite Setup Run Command tlm config set llm.model ${model}
Suite Teardown Run Command tlm config set llm.model ${model}

Test Tags command=ask

Name tlm ask


*** Variables ***
${model} qwen2.5-coder:3b


*** Test Cases ***
tlm ask <command>
${rc} ${output}= Run Command tlm ask "Why the sky is blue? Name the concept."

Should Be Equal As Integers ${rc} 0
Should Contain ${output} Rayleigh scatte

${rc} ${output}= Run Command tlm a "Why the sky is blue? Name the concept."

Should Be Equal As Integers ${rc} 0
Should Contain ${output} Rayleigh scattering

tlm ask --context=<context> --include=<patterns> <command>
${rc} ${output}= Run Command tlm ask --context=. --include=**/*.robot "explain provided context"
${expected_file_list}= Create List tests/ask.robot tests/suggest.robot tests/help.robot

Verify Ask Command Output With Context
... ${rc}
... ${output}
... ${expected_file_list}

tlm ask --context=<context> --exclude=<patterns> <command>
${rc} ${output}= Run Command tlm ask --context=. --exclude=**/*.robot "explain provided context"
${expected_file_list}= Create List tlm.robot tlm.resource tlm_lib.py requirements.txt
Verify Ask Command Output With Context
... ${rc}
... ${output}
... ${expected_file_list}

tlm ask (no ollama)
[Tags] no-ollama
# Test that the command fails when OLLAMA_HOST is not set
Remove Environment Variable OLLAMA_HOST
${rc} ${output}= Run Command tlm ask "What is the meaning of life?"
Should Not Be Equal As Integers ${rc} 0
Should Contain ${output} (err)
Should Contain
... ${output}
... OLLAMA_HOST environment variable is not set

# Test the command fails when OLLAMA_HOST is set but not reachable
Set Environment Variable OLLAMA_HOST http://localhost:11434
${rc} ${output}= Run Command tlm ask "What is the meaning of life?"

Should Not Be Equal As Integers ${rc} 0
Should Contain ${output} (err)
Should Contain
... ${output}
... Ollama connection failed. Please check your Ollama if it's running or configured correctly.

tlm ask (non-exist model)
${model}= Set Variable non-exist-model:1b
Run Command tlm config set llm.model ${model}

${rc} ${output}= Run Command tlm ask 'What is the meaning of life?'
Should Not Be Equal As Integers ${rc} 0
Should Contain ${output} model "${model}" not found, try pulling it first


*** Keywords ***
Verify Ask Command Output With Context
[Arguments] ${rc} ${output} ${expected_file_list}

Should Be Equal As Numbers ${rc} 0

FOR ${file} IN @{expected_file_list}
Should Contain ${output} ${file}
END

Should Contain ${output} Context Summary:
Should Contain ${output} Total Files:
Should Contain ${output} Total Chars:
Should Contain ${output} Total Tokens:
29 changes: 29 additions & 0 deletions e2e/tests/help.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
*** Settings ***
Library Collections
Resource ../tlm.resource

Name tlm help


*** Test Cases ***
tlm help
[Tags] command=help
${rc} ${output}= Run Command tlm help
Verify Help Command Output ${rc} ${output}


*** Keywords ***
Verify Help Command Output
[Arguments] ${rc} ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} NAME:
Should Contain ${output} USAGE:

Should Contain ${output} VERSION:

Should Contain ${output} COMMANDS:
Should Contain ${output} ask, a Asks a question
Should Contain ${output} suggest, s Suggests a command.
Should Contain ${output} explain, e Explains a command.
Should Contain ${output} config, c Configures language model, style and shell
Should Contain ${output} version, v Prints tlm version.
32 changes: 32 additions & 0 deletions e2e/tests/suggest.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
*** Settings ***
Resource ../tlm.resource

Suite Setup Run Command tlm config set llm.model ${model}

Test Tags command=suggest

Name tlm suggest


*** Variables ***
${model} qwen2.5-coder:1.5b


*** Test Cases ***
tlm suggest <prompt>
${output}= Run Suggestion And Verify Output tlm suggest "list all files"
Should Contain ${output} ${model} is thinking...
Should Contain ${output} ls

Should Contain ${output} Execute
Should Contain ${output} Explain
Should Contain ${output} Cancel

tlm s <prompt>
${output}= Run Suggestion And Verify Output tlm s "list all files"
Should Contain ${output} ${model} is thinking...
Should Contain ${output} ls

Should Contain ${output} Execute
Should Contain ${output} Explain
Should Contain ${output} Cancel
12 changes: 12 additions & 0 deletions e2e/tests/version.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*** Settings ***
Library Collections
Resource ../tlm.resource

Name tlm version


*** Test Cases ***
tlm version
${rc} ${output}= Run Version
Should Be Equal As Integers ${rc} 0
Version Should Be Correct ${output}
157 changes: 0 additions & 157 deletions e2e/tlm.robot

This file was deleted.

Loading

0 comments on commit daec901

Please sign in to comment.