Skip to content

Commit 30cf867

Browse files
committed
integration tests
1 parent 9c99b5d commit 30cf867

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ The example currently supports the following commands:
155155
instead of a hardcoded value.
156156
- `attachment`: Adds an attachment, which is currently defined as the
157157
`CMakeCache.txt` file, which is part of the CMake build folder.
158+
- `attach-after-init`: Same as `attachment` but after the SDK has been initialized.
158159
- `stdout`: Uses a custom transport which dumps all envelopes to `stdout`.
159160
- `no-setup`: Skips all scope and breadcrumb initialization code.
160161
- `start-session`: Starts a new release-health session.
@@ -185,6 +186,7 @@ The example currently supports the following commands:
185186
This file can be found in `./tests/fixtures/view-hierachy.json`.
186187
- `set-trace`: Sets the scope `propagation_context`'s trace data to the given `trace_id="aaaabbbbccccddddeeeeffff00001111"` and `parent_span_id=""f0f0f0f0f0f0f0f0"`.
187188
- `capture-with-scope`: Captures an event with a local scope.
189+
- `attach-to-scope`: Same as `attachment` but attaches the file to the local scope.
188190

189191
Only on Linux using crashpad:
190192
- `crashpad-wait-for-upload`: Couples application shutdown to complete the upload in the `crashpad_handler`.

examples/example.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ main(int argc, char **argv)
399399
sentry_set_trace(direct_trace_id, direct_parent_span_id);
400400
}
401401

402+
if (has_arg(argc, argv, "attach-after-init")) {
403+
// assuming the example / test is run directly from the cmake build
404+
// directory
405+
sentry_add_attachment("./CMakeCache.txt");
406+
}
407+
402408
if (has_arg(argc, argv, "start-session")) {
403409
sentry_start_session();
404410
}
@@ -424,6 +430,12 @@ main(int argc, char **argv)
424430
sentry_value_t debug_crumb = create_debug_crumb("scoped crumb");
425431
sentry_scope_add_breadcrumb(scope, debug_crumb);
426432

433+
if (has_arg(argc, argv, "attach-to-scope")) {
434+
// assuming the example / test is run directly from the cmake build
435+
// directory
436+
sentry_scope_add_attachment(scope, "./CMakeCache.txt");
437+
}
438+
427439
sentry_capture_event_with_scope(event, scope);
428440
}
429441

tests/test_integration_crashpad.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ def test_crashpad_wer_crash(cmake, httpserver, run_args):
289289
"run_args,build_args",
290290
[
291291
# if we crash, we want a dump
292-
([], {"SENTRY_TRANSPORT_COMPRESSION": "Off"}),
293-
([], {"SENTRY_TRANSPORT_COMPRESSION": "On"}),
292+
(["attachment"], {"SENTRY_TRANSPORT_COMPRESSION": "Off"}),
293+
(["attachment"], {"SENTRY_TRANSPORT_COMPRESSION": "On"}),
294294
# if we crash and before-send doesn't discard, we want a dump
295295
pytest.param(
296-
["before-send"],
296+
["attachment", "before-send"],
297297
{},
298298
marks=pytest.mark.skipif(
299299
sys.platform == "darwin",
@@ -302,13 +302,21 @@ def test_crashpad_wer_crash(cmake, httpserver, run_args):
302302
),
303303
# if on_crash() is non-discarding, a discarding before_send() is overruled, so we get a dump
304304
pytest.param(
305-
["discarding-before-send", "on-crash"],
305+
["attachment", "discarding-before-send", "on-crash"],
306306
{},
307307
marks=pytest.mark.skipif(
308308
sys.platform == "darwin",
309309
reason="crashpad doesn't provide SetFirstChanceExceptionHandler on macOS",
310310
),
311311
),
312+
pytest.param(
313+
["attach-after-init"],
314+
{},
315+
marks=pytest.mark.skipif(
316+
sys.platform == "darwin",
317+
reason="crashpad doesn't support dynamic attachments on macOS",
318+
),
319+
),
312320
],
313321
)
314322
def test_crashpad_dumping_crash(cmake, httpserver, run_args, build_args):
@@ -329,7 +337,6 @@ def test_crashpad_dumping_crash(cmake, httpserver, run_args, build_args):
329337
[
330338
"log",
331339
"start-session",
332-
"attachment",
333340
"attach-view-hierarchy",
334341
"overflow-breadcrumbs",
335342
"crash",

tests/test_integration_http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ def test_capture_with_scope(cmake, httpserver):
11731173
run(
11741174
tmp_path,
11751175
"sentry_example",
1176-
["log", "attachment", "capture-with-scope"],
1176+
["log", "attach-to-scope", "capture-with-scope"],
11771177
check=True,
11781178
env=dict(os.environ, SENTRY_DSN=make_dsn(httpserver)),
11791179
)

0 commit comments

Comments
 (0)