Skip to content

Commit 426c605

Browse files
authored
docs: windows test and formatter runners (#1247)
1 parent 3d15dda commit 426c605

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Provide `before_send_transaction` callback. ([#1236](https://github.com/getsentry/sentry-native/pull/1236))
88

9+
**Docs**:
10+
11+
- Document convenience Powershell runners for formatting and tests on Windows. ([#1247](https://github.com/getsentry/sentry-native/pull/1247))
12+
913
## 0.8.5
1014

1115
**Breaking changes**:
@@ -15,7 +19,7 @@
1519
**Features**:
1620

1721
- Add `sentry_value_new_user(id, username, email, ip_address)` function to avoid ambiguous user-context-keys. ([#1228](https://github.com/getsentry/sentry-native/pull/1228))
18-
22+
1923
**Fixes**:
2024

2125
- Remove compile-time check for the `libcurl` feature `AsynchDNS`. ([#1206](https://github.com/getsentry/sentry-native/pull/1206))

CONTRIBUTING.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ be done manually.
3232

3333
$ black tests
3434

35+
In Powershell on Windows you can use
36+
37+
$ .\scripts\run_formatters.ps1
38+
39+
to invoke both formatters.
40+
3541
## Running Tests
3642

3743
$ make test
@@ -40,6 +46,21 @@ Creates a python virtualenv, and runs all the tests through `pytest`.
4046

4147
To run our `HTTP` proxy tests, one must add `127.0.0.1 sentry.native.test` to the `hosts` file. This is required since some transports bypass the proxy otherwise (for [example on Windows](https://learn.microsoft.com/en-us/windows/win32/wininet/enabling-internet-functionality#listing-the-proxy-bypass)).
4248

49+
**Running tests on Windows**:
50+
51+
The `make` scripts are not written with Windows in mind, since most Windows users use Visual Studio (Code) or CLion,
52+
which all have elaborate build- and run-configuration capabilities that rarely require to fall back to CLI.
53+
54+
However, if you want to run the tests from Powershell we added a convenience script
55+
56+
$ .\scripts\run_tests.ps1
57+
58+
that provides the ease of the `make`-based build with a couple of parameters which you can query with
59+
60+
$ Get-Help .\scripts\run_tests.ps1 -detailed
61+
62+
It depends on `.\scripts\update_test_discovery.ps1` which updates the unit-test index like the `make` target of the same
63+
name.
4364

4465
**Running integration tests manually**:
4566

@@ -160,12 +181,12 @@ The example currently supports the following commands:
160181
- `before-transaction`: Installs a `before_transaction()` callback that updates the transaction title.
161182
- `discarding-before-transaction`: Installs a `before_transaction()` callback that discards the transaction.
162183
- `traces-sampler`: Installs a traces sampler callback function when used alongside `capture-transaction`.
163-
- `attach-view-hierarchy`: Adds a `view-hierarchy.json` attachment file, giving it the proper `attachment_type` and `content_type`.
184+
- `attach-view-hierarchy`: Adds a `view-hierarchy.json` attachment file, giving it the proper `attachment_type` and `content_type`.
164185
This file can be found in `./tests/fixtures/view-hierachy.json`.
165186
- `set-trace`: Sets the scope `propagation_context`'s trace data to the given `trace_id="aaaabbbbccccddddeeeeffff00001111"` and `parent_span_id=""f0f0f0f0f0f0f0f0"`.
166-
187+
167188
Only on Linux using crashpad:
168-
- `crashpad-wait-for-upload`: Couples application shutdown to complete the upload in the `crashpad_handler`.
189+
- `crashpad-wait-for-upload`: Couples application shutdown to complete the upload in the `crashpad_handler`.
169190

170191
Only on Windows using crashpad with its WER handler module:
171192

scripts/run_tests.ps1

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1+
<#
2+
.SYNOPSIS
3+
A helper script to execute Native SDK tests in Windows PowerShell.
4+
.DESCRIPTION
5+
Maintains the venv, wraps pytest for execution, and invokes update_test_discovery.ps1 to collect newly added unit tests.
6+
#>
17
param (
8+
## Lets you run only the unit tests (default: false)
29
[switch]$Unit = $false,
10+
## Cleanly reinstalls packages into the venv (default: false)
311
[switch]$Clean = $false,
12+
## Lets you limit the test discovery to part of a name (default: all)
413
[string]$Keyword = "",
14+
## Defines the number of parallel runners via pytest-xdist. This is highly experimental since tests remove database paths. (default: 1)
515
[int]$Parallelism = 1,
16+
## Disables tests that require the crashpad WER module. (default: false)
617
[switch]$WithoutCrashpadWer = $false,
7-
[switch]$DisableCapture = $false
18+
## Disables stdout/stderr capture through pytest (default: false)
19+
[switch]$DisableCapture = $false,
20+
## Defines the maximum number of failing tests before the test session is stopped. 0 means infinite. Will not do what you expect, together with Parallelism > 1 (default: 0)
21+
[int]$MaxFail = 0,
22+
## Repeatedly runs the test suite (default: false)
23+
[switch]$Repeat = $false
824
)
925

1026
$update_test_discovery = Join-Path -Path $PSScriptRoot -ChildPath "update_test_discovery.ps1"
@@ -17,7 +33,7 @@ if ($Clean -or -not (Test-Path .\.venv))
1733
.\.venv\Scripts\pip.exe install --upgrade --requirement .\tests\requirements.txt
1834
}
1935

20-
$pytestCommand = ".\.venv\Scripts\pytest.exe .\tests\ --verbose"
36+
$pytestCommand = ".\.venv\Scripts\pytest.exe .\tests\ --verbose --maxfail=$MaxFail"
2137

2238
if ($DisableCapture) {
2339
$pytestCommand += " --capture=no"
@@ -42,4 +58,12 @@ elseif ($Unit)
4258
$pytestCommand += " -k `"unit`""
4359
}
4460

45-
Invoke-Expression $pytestCommand
61+
do {
62+
try {
63+
Invoke-Expression $pytestCommand
64+
65+
Start-Sleep -Seconds 1
66+
} catch {
67+
Write-Host "An error occurred: $_"
68+
}
69+
} while($Repeat)

0 commit comments

Comments
 (0)