Skip to content
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
7 changes: 6 additions & 1 deletion src/buildkite_test_collector/collector/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,24 @@ class TestData:
name: str
history: TestHistory
location: Optional[str] = None
file_name: Optional[str] = None
result: Union[TestResultPassed, TestResultFailed,
TestResultSkipped, None] = None

@classmethod
def start(cls, id: UUID,
*,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scope: str,
name: str,
location: Optional[str] = None) -> 'TestData':
location: Optional[str] = None,
file_name: Optional[str] = None) -> 'TestData':
"""Build a new instance with it's start_at time set to now"""
return cls(
id=id,
scope=scope,
name=name,
location=location,
file_name=file_name,
history=TestHistory(start_at=Instant.now())
)

Expand Down Expand Up @@ -167,6 +171,7 @@ def as_json(self, started_at: Instant) -> JsonDict:
"scope": self.scope,
"name": self.name,
"location": self.location,
"file_name": self.file_name,
"history": self.history.as_json(started_at)
}

Expand Down
11 changes: 7 additions & 4 deletions src/buildkite_test_collector/pytest_plugin/buildkite_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ def pytest_runtest_logstart(self, nodeid, location):
self.payload = self.payload.started()

chunks = nodeid.split("::")
scope = "::".join(chunks[:-1])
name = chunks[-1]
location = f"{location[0]}:{location[1]}"

test_data = TestData.start(uuid4(), scope, name, location)
test_data = TestData.start(
uuid4(),
scope="::".join(chunks[:-1]),
name=chunks[-1],
file_name=location[0],
location=f"{location[0]}:{location[1]}"
)
self.in_flight[nodeid] = test_data

def pytest_runtest_logreport(self, report):
Expand Down
1 change: 1 addition & 0 deletions tests/buildkite_test_collector/collector/test_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def test_test_data_as_json(incomplete_test):
assert json["scope"] == incomplete_test.scope
assert json["name"] == incomplete_test.name
assert json["location"] == incomplete_test.location
assert json["file_name"] == incomplete_test.file_name
assert json["history"] == incomplete_test.history.as_json(now)


Expand Down
2 changes: 2 additions & 0 deletions tests/buildkite_test_collector/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def successful_test(history_finished) -> TestData:
scope="wyld stallyns",
name="san dimas meltdown",
location="san_dimas_meltdown.py:1",
file_name="san_dimas_meltdown.py",
result=TestResultPassed(),
history=history_finished
)
Expand All @@ -40,6 +41,7 @@ def incomplete_test(history_started) -> TestData:
scope="wyld stallyns",
name="san dimas meltdown",
location="san_dimas_meltdown.py:1",
file_name="san_dimas_meltdown.py",
result=None,
history=history_started
)
Expand Down