Skip to content

Commit 956c8d2

Browse files
authored
Various fixes for tests/CI (#1206)
1 parent 3ff6631 commit 956c8d2

File tree

23 files changed

+140
-74
lines changed

23 files changed

+140
-74
lines changed
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
name: MSVC Tests
1+
name: CI Tests
22
on:
33
push:
44
pull_request:
55
branches:
66
- master
77

88
jobs:
9-
test-cppwinrt:
9+
test-msvc-cppwinrt:
10+
name: 'MSVC: Tests'
1011
strategy:
1112
matrix:
1213
arch: [x86, x64, arm64]
@@ -21,7 +22,7 @@ jobs:
2122
- name: Test all
2223
run: |
2324
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
24-
if (!$VSDevCmd) { return 1 }
25+
if (!$VSDevCmd) { exit 1 }
2526
echo "Using VSDevCmd: ${VSDevCmd}"
2627
cmd /c "${VSDevCmd}" "&" build_test_all.cmd ${{ matrix.arch }} ${{ matrix.config }}
2728
@@ -37,30 +38,31 @@ jobs:
3738
run: |
3839
if (Test-Path "test_failures.txt") {
3940
Get-Content "test_failures.txt" | ForEach-Object {
40-
Write-Error "error: Test '$_' failed!"
41+
echo "::error::Test '$_' failed!"
4142
}
42-
return 1
43+
exit 1
4344
}
4445
if (!(Test-Path "*_results.txt")) {
45-
Write-Error "error: No test output found!"
46-
return 1
46+
echo "::error::No test output found!"
47+
exit 1
4748
}
4849
4950
build-nuget:
51+
name: Build nuget package with MSVC
5052
runs-on: windows-latest
5153
steps:
5254
- uses: actions/checkout@v3
5355

5456
- name: Package
5557
run: |
5658
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
57-
if (!$VSDevCmd) { return 1 }
59+
if (!$VSDevCmd) { exit 1 }
5860
echo "Using VSDevCmd: ${VSDevCmd}"
5961
cmd /c "${VSDevCmd}" "&" nuget.exe restore cppwinrt.sln
6062
cmd /c "${VSDevCmd}" "&" build_nuget.cmd
6163
if (!(Test-Path "*.nupkg")) {
62-
Write-Error "error: Output nuget package not found!"
63-
return 1
64+
echo "::error::Output nuget package not found!"
65+
exit 1
6466
}
6567
6668
- name: Upload nuget package artifact

test/old_tests/UnitTests/Errors.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ TEST_CASE("Errors")
9393
try
9494
{
9595
init_apartment(apartment_type::single_threaded);
96-
FAIL(L"Previous line should throw");
96+
FAIL("Previous line should throw");
9797
}
9898
catch (hresult_error const & e)
9999
{
@@ -104,7 +104,7 @@ TEST_CASE("Errors")
104104
try
105105
{
106106
Uri uri(L"BAD");
107-
FAIL(L"Previous line should throw");
107+
FAIL("Previous line should throw");
108108
}
109109
catch (hresult_invalid_argument const & e) // catching specific exception type
110110
{
@@ -115,7 +115,7 @@ TEST_CASE("Errors")
115115
try
116116
{
117117
Uri uri(L"BAD");
118-
FAIL(L"Previous line should throw");
118+
FAIL("Previous line should throw");
119119
}
120120
catch (hresult_error const& e)
121121
{
@@ -128,7 +128,7 @@ TEST_CASE("Errors")
128128
{
129129
Errors errors;
130130
errors.Propagate();
131-
FAIL(L"Previous line should throw");
131+
FAIL("Previous line should throw");
132132
}
133133
catch (hresult_invalid_argument const & e) // catching specific exception type
134134
{
@@ -140,7 +140,7 @@ TEST_CASE("Errors")
140140
{
141141
Errors errors;
142142
errors.Fail(L"Failure message");
143-
FAIL(L"Previous line should throw");
143+
FAIL("Previous line should throw");
144144
}
145145
catch (hresult_not_implemented const& e)
146146
{
@@ -158,7 +158,7 @@ TEST_CASE("Errors")
158158
{
159159
Errors errors;
160160
errors.std_out_of_range();
161-
FAIL(L"Previous line should throw");
161+
FAIL("Previous line should throw");
162162
}
163163
catch (hresult_out_of_bounds const& e)
164164
{
@@ -169,7 +169,7 @@ TEST_CASE("Errors")
169169
{
170170
Errors errors;
171171
errors.std_invalid_argument();
172-
FAIL(L"Previous line should throw");
172+
FAIL("Previous line should throw");
173173
}
174174
catch (hresult_invalid_argument const& e)
175175
{
@@ -180,7 +180,7 @@ TEST_CASE("Errors")
180180
{
181181
Errors errors;
182182
errors.std_exception();
183-
FAIL(L"Previous line should throw");
183+
FAIL("Previous line should throw");
184184
}
185185
catch (hresult_error const& e)
186186
{
@@ -207,7 +207,7 @@ TEST_CASE("Errors")
207207
try
208208
{
209209
check_win32(ERROR_NO_NETWORK);
210-
FAIL(L"Previous line should throw");
210+
FAIL("Previous line should throw");
211211
}
212212
catch (hresult_error const& e)
213213
{
@@ -220,7 +220,7 @@ TEST_CASE("Errors")
220220
try
221221
{
222222
check_nt(STATUS_STACK_OVERFLOW);
223-
FAIL(L"Previous line should throw");
223+
FAIL("Previous line should throw");
224224
}
225225
catch (hresult_error const& e)
226226
{

test/old_tests/UnitTests/array.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ TEST_CASE("array,at,throw")
344344
try
345345
{
346346
a.at(3);
347-
FAIL(L"Previous line should throw");
347+
FAIL("Previous line should throw");
348348
}
349349
catch (std::out_of_range const & e)
350350
{
@@ -357,7 +357,7 @@ TEST_CASE("array,at,throw")
357357
try
358358
{
359359
test_array_ref_at_throw({ 1, 2, 3 });
360-
FAIL(L"Previous line should throw");
360+
FAIL("Previous line should throw");
361361
}
362362
catch (std::out_of_range const & e)
363363
{
@@ -372,7 +372,7 @@ TEST_CASE("array,at,throw")
372372
try
373373
{
374374
a.at(5);
375-
FAIL(L"Previous line should throw");
375+
FAIL("Previous line should throw");
376376
}
377377
catch (std::out_of_range const & e)
378378
{

test/old_tests/UnitTests/async.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ using namespace std::chrono;
1414

1515
namespace
1616
{
17+
#ifdef __cpp_lib_coroutine
18+
using std::suspend_never;
19+
#else
20+
using std::experimental::suspend_never;
21+
#endif
22+
1723
IAsyncAction NoSuspend_IAsyncAction()
1824
{
1925
co_await 0s;
@@ -1032,23 +1038,23 @@ namespace
10321038
{
10331039
signal_done d{ go };
10341040
co_await resume_on_signal(go);
1035-
co_await std::experimental::suspend_never{};
1041+
co_await suspend_never{};
10361042
REQUIRE(false);
10371043
}
10381044

10391045
IAsyncActionWithProgress<double> AutoCancel_IAsyncActionWithProgress(HANDLE go)
10401046
{
10411047
signal_done d{ go };
10421048
co_await resume_on_signal(go);
1043-
co_await std::experimental::suspend_never{};
1049+
co_await suspend_never{};
10441050
REQUIRE(false);
10451051
}
10461052

10471053
IAsyncOperation<uint32_t> AutoCancel_IAsyncOperation(HANDLE go)
10481054
{
10491055
signal_done d{ go };
10501056
co_await resume_on_signal(go);
1051-
co_await std::experimental::suspend_never{};
1057+
co_await suspend_never{};
10521058
REQUIRE(false);
10531059
co_return 0;
10541060
}
@@ -1057,7 +1063,7 @@ namespace
10571063
{
10581064
signal_done d{ go };
10591065
co_await resume_on_signal(go);
1060-
co_await std::experimental::suspend_never{};
1066+
co_await suspend_never{};
10611067
REQUIRE(false);
10621068
co_return 0;
10631069
}

test/old_tests/UnitTests/hresult_error.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ TEST_CASE("hresult,S_FALSE")
2323
try
2424
{
2525
check_hresult(S_FALSE);
26-
FAIL(L"Previous line should throw");
26+
FAIL("Previous line should throw");
2727
}
2828
catch (hresult_error const & e)
2929
{
@@ -40,7 +40,7 @@ TEST_CASE("hresult,init_apartment")
4040
try
4141
{
4242
init_apartment(apartment_type::single_threaded);
43-
FAIL(L"Previous line should throw");
43+
FAIL("Previous line should throw");
4444
}
4545
catch (hresult_error const & e)
4646
{
@@ -55,7 +55,7 @@ TEST_CASE("hresult,restricted,consuming")
5555
try
5656
{
5757
Uri uri(L"BAD");
58-
FAIL(L"Previous line should throw");
58+
FAIL("Previous line should throw");
5959
}
6060
catch (hresult_invalid_argument const & e) // catching specific exception type
6161
{
@@ -66,7 +66,7 @@ TEST_CASE("hresult,restricted,consuming")
6666
try
6767
{
6868
Uri uri(L"BAD");
69-
FAIL(L"Previous line should throw");
69+
FAIL("Previous line should throw");
7070
}
7171
catch (hresult_error const & e) // catching generic exception type
7272
{
@@ -501,7 +501,7 @@ TEST_CASE("hresult, std abi support")
501501
};
502502

503503
handler(nullptr, 0);
504-
FAIL(L"Previous line should throw");
504+
FAIL("Previous line should throw");
505505
}
506506
catch (hresult_error const& e)
507507
{
@@ -517,7 +517,7 @@ TEST_CASE("hresult, std abi support")
517517
};
518518

519519
handler(nullptr, 0);
520-
FAIL(L"Previous line should throw");
520+
FAIL("Previous line should throw");
521521
}
522522
catch (std::bad_alloc const&)
523523
{
@@ -531,7 +531,7 @@ TEST_CASE("hresult, std abi support")
531531
};
532532

533533
handler(nullptr, 0);
534-
FAIL(L"Previous line should throw");
534+
FAIL("Previous line should throw");
535535
}
536536
catch (hresult_out_of_bounds const& e)
537537
{
@@ -547,7 +547,7 @@ TEST_CASE("hresult, std abi support")
547547
};
548548

549549
handler(nullptr, 0);
550-
FAIL(L"Previous line should throw");
550+
FAIL("Previous line should throw");
551551
}
552552
catch (hresult_invalid_argument const& e)
553553
{
@@ -575,4 +575,4 @@ TEST_CASE("hresult, to_message")
575575
{
576576
REQUIRE(to_message() == L"oh no, invalid handle");
577577
}
578-
}
578+
}

test/test/async_auto_cancel.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,42 @@ using namespace Windows::Foundation;
55

66
namespace
77
{
8+
#ifdef __cpp_lib_coroutine
9+
using std::suspend_never;
10+
#else
11+
using std::experimental::suspend_never;
12+
#endif
13+
814
//
915
// Checks that the coroutine is automatically canceled when reaching a suspension point.
1016
//
1117

1218
IAsyncAction Action(HANDLE event)
1319
{
1420
co_await resume_on_signal(event);
15-
co_await std::experimental::suspend_never();
21+
co_await suspend_never();
1622
REQUIRE(false);
1723
}
1824

1925
IAsyncActionWithProgress<int> ActionWithProgress(HANDLE event)
2026
{
2127
co_await resume_on_signal(event);
22-
co_await std::experimental::suspend_never();
28+
co_await suspend_never();
2329
REQUIRE(false);
2430
}
2531

2632
IAsyncOperation<int> Operation(HANDLE event)
2733
{
2834
co_await resume_on_signal(event);
29-
co_await std::experimental::suspend_never();
35+
co_await suspend_never();
3036
REQUIRE(false);
3137
co_return 1;
3238
}
3339

3440
IAsyncOperationWithProgress<int, int> OperationWithProgress(HANDLE event)
3541
{
3642
co_await resume_on_signal(event);
37-
co_await std::experimental::suspend_never();
43+
co_await suspend_never();
3844
REQUIRE(false);
3945
co_return 1;
4046
}
@@ -48,7 +54,7 @@ namespace
4854
auto cancel = co_await get_cancellation_token();
4955
cancel.callback(nullptr);
5056

51-
co_await std::experimental::suspend_never();
57+
co_await suspend_never();
5258
REQUIRE(false);
5359
}
5460

0 commit comments

Comments
 (0)