Skip to content

Commit

Permalink
Merge pull request #776 from launchableinc/fix-getting-stderr-logic
Browse files Browse the repository at this point in the history
Fix the logic of getting stderr for readability
  • Loading branch information
ono-max authored Feb 20, 2024
2 parents c48984e + 9c4c70a commit cdc1cda
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions launchable/commands/record/case_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ def stderr(case: TestCase) -> str:
stderr = ""
for result in case.result:
if type(result) in POSSIBLE_RESULTS:
if result.message and result.text:
stderr = stderr + result.message + "\n" + result.text
# Since the `message` property is a summary of the `text` property,
# we should attempt to retrieve the `text` property first in order to obtain a detailed log.
if result.text:
stderr = stderr + result.text
elif result.message:
stderr = stderr + result.message + "\n"
elif result.text:
stderr = stderr + result.text

return stderr

Expand Down
2 changes: 1 addition & 1 deletion tests/data/ant/record_test_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"duration": 0.006,
"status": 0,
"stdout": "",
"stderr": "An error message\njunit.framework.AssertionFailedError: An error message\n\tat com.launchable.HelloWorldTest.testWillAlwaysFail(Unknown Source)\n",
"stderr": "junit.framework.AssertionFailedError: An error message\n\tat com.launchable.HelloWorldTest.testWillAlwaysFail(Unknown Source)\n",
"created_at": "2021-04-28T10:36:31",
"data": null
},
Expand Down
2 changes: 1 addition & 1 deletion tests/data/googletest/fail/record_test_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"duration": 0.001,
"status": 0,
"stdout": "",
"stderr": "github.com/launchableinc/rocket-car-googletest/test_a.cpp:21\nExpected equality of these values:\n false\n true\ngithub.com/launchableinc/rocket-car-googletest/test_a.cpp:21\nExpected equality of these values:\n false\n true",
"stderr": "github.com/launchableinc/rocket-car-googletest/test_a.cpp:21\nExpected equality of these values:\n false\n true",
"created_at": "2021-01-26T14:56:53",
"data": null
},
Expand Down
6 changes: 3 additions & 3 deletions tests/data/playwright/record_test_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@
"duration": 5.417,
"status": 0,
"stdout": "",
"stderr": "example.spec.ts:10:5 get started link\n\n [chromium] \u203a tests/example.spec.ts:10:5 \u203a get started link \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n Error: Timed out 5000ms waiting for expect(locator).toBeVisible()\n\n Locator: getByRole('heading', { name: 'Installation!' })\n Expected: visible\n Received: hidden\n Call log:\n - expect.toBeVisible with timeout 5000ms\n - waiting for getByRole('heading', { name: 'Installation!' })\n\n\n 15 |\n 16 | // Expects page to have a heading with the name of Installation.\n > 17 | await expect(page.getByRole('heading', { name: 'Installation!' })).toBeVisible();\n | ^\n 18 | });\n 19 |\n\n at /Users/yabuki-ryosuke/src/github.com/launchableinc/examples/playwright/tests/example.spec.ts:17:70\n\n",
"stderr": "\n [chromium] \u203a tests/example.spec.ts:10:5 \u203a get started link \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n Error: Timed out 5000ms waiting for expect(locator).toBeVisible()\n\n Locator: getByRole('heading', { name: 'Installation!' })\n Expected: visible\n Received: hidden\n Call log:\n - expect.toBeVisible with timeout 5000ms\n - waiting for getByRole('heading', { name: 'Installation!' })\n\n\n 15 |\n 16 | // Expects page to have a heading with the name of Installation.\n > 17 | await expect(page.getByRole('heading', { name: 'Installation!' })).toBeVisible();\n | ^\n 18 | });\n 19 |\n\n at /Users/yabuki-ryosuke/src/github.com/launchableinc/examples/playwright/tests/example.spec.ts:17:70\n\n",
"created_at": "2024-01-31T07:12:52.585Z",
"data": null
},
Expand Down Expand Up @@ -984,7 +984,7 @@
"duration": 6.048,
"status": 0,
"stdout": "",
"stderr": "example.spec.ts:10:5 get started link\n\n [firefox] \u203a tests/example.spec.ts:10:5 \u203a get started link \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n Error: Timed out 5000ms waiting for expect(locator).toBeVisible()\n\n Locator: getByRole('heading', { name: 'Installation!' })\n Expected: visible\n Received: hidden\n Call log:\n - expect.toBeVisible with timeout 5000ms\n - waiting for getByRole('heading', { name: 'Installation!' })\n\n\n 15 |\n 16 | // Expects page to have a heading with the name of Installation.\n > 17 | await expect(page.getByRole('heading', { name: 'Installation!' })).toBeVisible();\n | ^\n 18 | });\n 19 |\n\n at /Users/yabuki-ryosuke/src/github.com/launchableinc/examples/playwright/tests/example.spec.ts:17:70\n\n",
"stderr": "\n [firefox] \u203a tests/example.spec.ts:10:5 \u203a get started link \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n Error: Timed out 5000ms waiting for expect(locator).toBeVisible()\n\n Locator: getByRole('heading', { name: 'Installation!' })\n Expected: visible\n Received: hidden\n Call log:\n - expect.toBeVisible with timeout 5000ms\n - waiting for getByRole('heading', { name: 'Installation!' })\n\n\n 15 |\n 16 | // Expects page to have a heading with the name of Installation.\n > 17 | await expect(page.getByRole('heading', { name: 'Installation!' })).toBeVisible();\n | ^\n 18 | });\n 19 |\n\n at /Users/yabuki-ryosuke/src/github.com/launchableinc/examples/playwright/tests/example.spec.ts:17:70\n\n",
"created_at": "2024-01-31T07:12:52.585Z",
"data": null
},
Expand Down Expand Up @@ -1478,7 +1478,7 @@
"duration": 5.586,
"status": 0,
"stdout": "",
"stderr": "example.spec.ts:10:5 get started link\n\n [webkit] \u203a tests/example.spec.ts:10:5 \u203a get started link \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n Error: Timed out 5000ms waiting for expect(locator).toBeVisible()\n\n Locator: getByRole('heading', { name: 'Installation!' })\n Expected: visible\n Received: hidden\n Call log:\n - expect.toBeVisible with timeout 5000ms\n - waiting for getByRole('heading', { name: 'Installation!' })\n\n\n 15 |\n 16 | // Expects page to have a heading with the name of Installation.\n > 17 | await expect(page.getByRole('heading', { name: 'Installation!' })).toBeVisible();\n | ^\n 18 | });\n 19 |\n\n at /Users/yabuki-ryosuke/src/github.com/launchableinc/examples/playwright/tests/example.spec.ts:17:70\n\n",
"stderr": "\n [webkit] \u203a tests/example.spec.ts:10:5 \u203a get started link \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n Error: Timed out 5000ms waiting for expect(locator).toBeVisible()\n\n Locator: getByRole('heading', { name: 'Installation!' })\n Expected: visible\n Received: hidden\n Call log:\n - expect.toBeVisible with timeout 5000ms\n - waiting for getByRole('heading', { name: 'Installation!' })\n\n\n 15 |\n 16 | // Expects page to have a heading with the name of Installation.\n > 17 | await expect(page.getByRole('heading', { name: 'Installation!' })).toBeVisible();\n | ^\n 18 | });\n 19 |\n\n at /Users/yabuki-ryosuke/src/github.com/launchableinc/examples/playwright/tests/example.spec.ts:17:70\n\n",
"created_at": "2024-01-31T07:12:52.585Z",
"data": null
}
Expand Down
4 changes: 2 additions & 2 deletions tests/data/prove/record_test_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"duration": 2.0633590221405,
"status": 0,
"stdout": "",
"stderr": "not ok 1 - add(1, 2) == 5\nnot ok 1 - add(1, 2) == 5\n# Subtest: add\n not ok 1 - 1 + 2\n 1..1",
"stderr": "not ok 1 - add(1, 2) == 5\n# Subtest: add\n not ok 1 - 1 + 2\n 1..1",
"data": null
},
{
Expand All @@ -51,7 +51,7 @@
"duration": 2.1068799495697,
"status": 0,
"stdout": "",
"stderr": "not ok 2 - add\nnot ok 2 - add",
"stderr": "not ok 2 - add",
"data": null
},
{
Expand Down
4 changes: 2 additions & 2 deletions tests/data/pytest/record_test_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"duration": 0.001,
"status": 0,
"stdout": "",
"stderr": "assert 1 == False\ndef test_func5():\n > assert 1 == False\n E assert 1 == False\n\n tests/funcs3_test.py:6: AssertionError ",
"stderr": "def test_func5():\n > assert 1 == False\n E assert 1 == False\n\n tests/funcs3_test.py:6: AssertionError ",
"created_at": "2021-12-09T14:09:43.746900",
"data": null
},
Expand Down Expand Up @@ -88,7 +88,7 @@
"duration": 0.001,
"status": 0,
"stdout": "",
"stderr": "assert 1 == False\ndef test_func2():\n > assert 1 == False\n E assert 1 == False\n\n tests/test_funcs1.py:6: AssertionError ",
"stderr": "def test_func2():\n > assert 1 == False\n E assert 1 == False\n\n tests/test_funcs1.py:6: AssertionError ",
"created_at": "2021-12-09T14:09:43.746900",
"data": null
},
Expand Down

0 comments on commit cdc1cda

Please sign in to comment.