Skip to content

Commit 867a93e

Browse files
authored
Merge pull request #10 from rmbar/issue_4
#4 merge solution into master
2 parents 36df423 + 533c67e commit 867a93e

9 files changed

Lines changed: 13 additions & 30 deletions

File tree

src/main/python/accept.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ def run_shell_command(command: str, expected_exit: int, expected_stdout: str = N
124124
completed_process = subprocess.run(command, shell=True, stdout=subprocess.PIPE)
125125

126126
if len(completed_process.stdout) > 0:
127-
print(HEADER + "<begin stdout>" + END_COLOR)
128-
print(completed_process.stdout.decode('utf-8'))
129-
print(HEADER + "<end stdout>" + END_COLOR)
127+
print(HEADER + "<begin stdout>" + END_COLOR + completed_process.stdout.decode('utf-8') +
128+
HEADER + "<end stdout>" + END_COLOR)
130129

131130
#
132131
# Check if the exit code and standard out match expectations if specified.
@@ -135,9 +134,9 @@ def run_shell_command(command: str, expected_exit: int, expected_stdout: str = N
135134

136135
if expected_stdout is not None and expected_stdout != completed_process.stdout.decode('utf-8'):
137136
test_passed = False
138-
print(FAIL + "<expected stdout>" + END_COLOR)
139-
print(expected_stdout)
140-
print(FAIL + "<expected stdout>" + END_COLOR)
137+
print(FAIL + "<expected out>" + END_COLOR + expected_stdout + FAIL + "<end expected out>" + END_COLOR)
138+
# n.b. we use the string "<expected out>" instead of "<expected stdout>" so same char length as "<begin stdout>"
139+
# and thus lines up visually.
141140

142141
if expected_exit is not None and expected_exit != completed_process.returncode:
143142
test_passed = False

tool_files/bash_tester/correct/echo_dog.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ found 1 tests.
1616

1717
[running: tests/echo_dog.test]
1818
shell command: echo dog
19-
<begin stdout>
20-
dog
21-
19+
<begin stdout>dog
2220
<end stdout>
2321
[PASSED]
2422


tool_files/bash_tester/correct/echo_dog_legacy.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ found 1 tests.
1616

1717
[running: tests/echo_dog_legacy.test]
1818
shell command: echo dog
19-
<begin stdout>
20-
dog
21-
19+
<begin stdout>dog
2220
<end stdout>
2321
[PASSED]
2422


tool_files/bash_tester/correct/echo_exit_0.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ found 1 tests.
1616

1717
[running: tests/echo_exit_0.test]
1818
shell command: echo dog
19-
<begin stdout>
20-
dog
21-
19+
<begin stdout>dog
2220
<end stdout>
2321
[PASSED]
2422


tool_files/bash_tester/correct/echo_exit_0_legacy.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ found 1 tests.
1616

1717
[running: tests/echo_exit_0_legacy.test]
1818
shell command: echo dog
19-
<begin stdout>
20-
dog
21-
19+
<begin stdout>dog
2220
<end stdout>
2321
[PASSED]
2422


tool_files/bash_tester/correct/echo_exit_1.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ found 1 tests.
1616

1717
[running: tests/echo_exit_1.test]
1818
shell command: echo dog
19-
<begin stdout>
20-
dog
21-
19+
<begin stdout>dog
2220
<end stdout>
2321
<expected error code 1 but found 0>
2422
[FAILED]

tool_files/bash_tester/correct/echo_exit_1_legacy.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ found 1 tests.
1616

1717
[running: tests/echo_exit_1_legacy.test]
1818
shell command: echo dog
19-
<begin stdout>
20-
dog
21-
19+
<begin stdout>dog
2220
<end stdout>
2321
<expected error code 1 but found 0>
2422
[FAILED]

tool_files/bash_tester/correct/echo_just_command.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ found 1 tests.
1616

1717
[running: tests/echo_just_command.test]
1818
shell command: echo dog
19-
<begin stdout>
20-
dog
21-
19+
<begin stdout>dog
2220
<end stdout>
2321
[PASSED]
2422


tool_files/bash_tester/correct/echo_just_command_legacy.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ found 1 tests.
1616

1717
[running: tests/echo_just_command_legacy.test]
1818
shell command: echo dog
19-
<begin stdout>
20-
dog
21-
19+
<begin stdout>dog
2220
<end stdout>
2321
[PASSED]
2422


0 commit comments

Comments
 (0)