Skip to content

Commit 8e533a6

Browse files
committed
fix: fix gitignore
1 parent 98aa630 commit 8e533a6

File tree

7 files changed

+106
-1
lines changed

7 files changed

+106
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,6 @@ dist
176176
docs/
177177
template-bun-executable
178178
/.releaserc
179-
functional_tests/features/support/__pycache__/pexpect_wrapper.cpython-311.pyc
179+
functional_tests/features/support/__pycache__
180180
example-host-application
181+
functional_tests/.venv

functional_tests/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Executable Functional Tests
2+
3+
#### Setup
4+
5+
Ensure the executable is built:
6+
7+
bun build ../index.ts --compile --outfile /tmp/example-host-application
8+
9+
Install requirements:
10+
11+
pip3 install -r pip-requirements.txt
12+
13+
#### Testing
14+
15+
Run the functional tests:
16+
17+
export EXECUTABLE=/tmp/example-host-application
18+
behave
19+
20+
To run with logging output from the test steps (this is the best set of
21+
arguments I can find):
22+
23+
behave --no-logcapture --no-color --logging-level=DEBUG
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import os
2+
3+
from support.pexpect_wrapper import PExpectWrapper
4+
5+
6+
def before_all(context):
7+
8+
context.config.setup_logging()
9+
context.pexpect_wrapper = PExpectWrapper(os.environ.get('EXECUTABLE'))
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Feature: Executable
2+
3+
Scenario: Executable success
4+
When the executable is launched
5+
Then the executable should complete successfully
6+
And the executable should have output "INFO Invoking extension"
7+
And the executable should have output "INFO hello world"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from behave import when, then
2+
3+
4+
@when('the executable is launched')
5+
def step_impl(context):
6+
context.pexpect_wrapper.start()
7+
8+
9+
@then('the executable should complete successfully')
10+
def step_impl(context):
11+
context.pexpect_wrapper.expect_eof()
12+
status = context.pexpect_wrapper.complete()
13+
assert status == 0, 'unexpected exit status: {}'.format(status)
14+
15+
16+
@then('the executable should have output "{message}"')
17+
def step_impl(context, message):
18+
context.pexpect_wrapper.expect(message)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from pexpect.popen_spawn import PopenSpawn
2+
from pexpect import EOF
3+
import logging
4+
log = logging.getLogger("pexpect_wrapper")
5+
6+
7+
class PExpectWrapper:
8+
9+
def __init__(self, executable):
10+
self.executable = executable
11+
self.child = None
12+
self.output = None
13+
14+
def start(self):
15+
assert self.child is None
16+
17+
self.child = PopenSpawn(self.executable, encoding='utf-8')
18+
19+
def expect(self, message):
20+
assert self.child is not None
21+
22+
found = ''
23+
while len(self.output) > 0:
24+
next_line = self.output.pop(0)
25+
log.debug('looking for "{}" in "{}"'.format(message, next_line))
26+
if message in next_line:
27+
found = next_line
28+
break
29+
30+
assert found != '', 'expected {} in output'.format(message)
31+
32+
33+
def expect_eof(self):
34+
assert self.child is not None
35+
36+
self.child.expect(EOF)
37+
38+
def complete(self):
39+
assert self.child is not None
40+
41+
exit_status = self.child.wait()
42+
43+
self.output = self.child.before.split('\n')
44+
45+
return exit_status
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pexpect
2+
behave

0 commit comments

Comments
 (0)