Skip to content

Commit 47c2656

Browse files
authored
Basic end-to-end test setup (#15)
* Basic integration test setup * Migrate to unpackaged * Support packaged and unpacked profiles * Add some basic e2e tests * Added packer for win10/11 images * Add packer scripts * Include sub directories * Restructure * Restructure * Updated workflow * Add dispatch * Install node * Improvements Cleanup Fix boot Fix boot Fix paths Fix path Refactor Enable for all ports Cleanup names Install packer Refactor Fix step Fix actions * Allow access to private sub modules * Extend e2e tests * trigger build pipeline * Use bash * Update submodule * Change submodule url * Simplify checkout * Fix lint errors * Skip tests when arm64
1 parent 5c65d4c commit 47c2656

33 files changed

+1081
-92
lines changed

.editorconfig

+15-6
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ dotnet_style_readonly_field = true:suggestion
5151
dotnet_style_object_initializer = true:suggestion
5252
dotnet_style_collection_initializer = true:suggestion
5353
dotnet_style_explicit_tuple_names = true:suggestion
54-
dotnet_style_null_propagation =true:error
55-
dotnet_style_coalesce_expression =true:error
54+
dotnet_style_null_propagation = true:error
55+
dotnet_style_coalesce_expression = true:error
5656
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
5757
dotnet_style_prefer_inferred_tuple_names = true:suggestion
5858
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
@@ -67,7 +67,7 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case
6767
# Use PascalCase for constant fields
6868
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
6969
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
70-
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
70+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
7171
dotnet_naming_symbols.constant_fields.applicable_kinds = field
7272
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
7373
dotnet_naming_symbols.constant_fields.required_modifiers = const
@@ -76,6 +76,10 @@ dotnet_diagnostic.CA1823.severity=error
7676
dotnet_diagnostic.CA1836.severity=error
7777
dotnet_style_namespace_match_folder=true:error
7878
dotnet_style_allow_multiple_blank_lines_experimental=true:error
79+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
80+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
81+
tab_width = 4
82+
dotnet_diagnostic.VSTHRD111.severity = error
7983
###############################
8084
# C# Coding Conventions #
8185
###############################
@@ -100,7 +104,7 @@ csharp_style_conditional_delegate_call = true:suggestion
100104
# Modifier preferences
101105
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
102106
# Expression-level preferences
103-
csharp_prefer_braces =true:error
107+
csharp_prefer_braces = true:error
104108
csharp_style_deconstructed_variable_declaration = true:suggestion
105109
csharp_prefer_simple_default_expression = true:suggestion
106110
csharp_style_pattern_local_over_anonymous_function = true:suggestion
@@ -154,7 +158,7 @@ dotnet_diagnostic.VSTHRD200.severity = error
154158
dotnet_diagnostic.MA0048.severity = error
155159

156160
# MA0004: Use Task.ConfigureAwait(false)
157-
dotnet_diagnostic.MA0004.severity = error
161+
dotnet_diagnostic.MA0004.severity = none
158162

159163
# CS8618: Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
160164
dotnet_diagnostic.CS8618.severity = error
@@ -170,8 +174,13 @@ dotnet_diagnostic.MA0044.severity=error
170174

171175
# VSTHRD001: Avoid legacy thread switching APIs
172176
dotnet_diagnostic.VSTHRD001.severity = none
173-
csharp_style_namespace_declarations=file_scoped:error
177+
csharp_style_namespace_declarations= file_scoped:error
174178
csharp_style_unused_value_assignment_preference=discard_variable:error
179+
csharp_using_directive_placement = outside_namespace:silent
180+
csharp_prefer_simple_using_statement = true:suggestion
181+
csharp_style_prefer_method_group_conversion = true:silent
182+
csharp_style_expression_bodied_lambdas = true:silent
183+
csharp_style_expression_bodied_local_functions = false:silent
175184

176185
[*.vb]
177186
# Modifier preferences

.github/workflows/validate.yml

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
steps:
2929
- name: Checkout
3030
uses: actions/checkout@v2
31+
with:
32+
submodules: true
33+
ssh-key: ${{ secrets.WINSTRUMENTA_E2E_SSH_PRIVATE_KEY }}
3134
- name: Setup .NET SDK
3235
uses: actions/setup-dotnet@v1
3336
with:
@@ -43,4 +46,5 @@ jobs:
4346
- name: Build
4447
run: msbuild /m /t:build /restore /p:Configuration=Release /p:Platform=${{ matrix.platform }} /p:AppxPackage=false /m Winstrumenta.sln
4548
- name: Test
49+
if: ${{ matrix.platform != 'arm64' }} # skip arm64 tests since github runners are only x86 and x64 but not arm64
4650
run: Get-ChildItem -Recurse -Filter "*.Tests.dll" | ? { $_.FullName -Match "bin.[^.]+.Release" -and $_.FullName -notmatch "ref" } | % { vstest.console.exe $_.FullName }

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ ipch/
115115
*.vspx
116116
*.sap
117117

118-
# Visual Studio Trace Files
119-
*.e2e
120-
121118
# TFS 2012 Local Workspace
122119
$tf/
123120

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "Windows.Tests.e2e"]
2+
path = Windows.Tests.e2e
3+
url = ../Winstrumenta.e2e.git

.onsaveconfig

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ command = dotnet
88
arguments = pprettier --write "{file}"
99
always_run = true
1010

11-
[*.{xml,csproj,xaml,appxmanifest,props,wapproj}]
11+
[*.{xml,csproj,xaml,appxmanifest,props,wapproj,Build.props,msbuildproj}]
1212
command = dotnet
1313
arguments = pprettier --write "{file}" --plugin "<NodeModulesPath>/@prettier/plugin-xml" --parser "xml" --print-width 120 --xml-whitespace-sensitivity "ignore" --tab-width 4
1414
always_run = true
@@ -17,3 +17,8 @@ always_run = true
1717
command = dotnet
1818
arguments = pprettier --write "{file}" --plugin "<NodeModulesPath>/prettier-plugin-sh"
1919
always_run = true
20+
21+
[*.hcl]
22+
command = packer
23+
arguments = fmt "{file}"
24+
always_run = true
38.8 MB
Binary file not shown.

Directory.Build.props

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<Project>
2-
<PropertyGroup>
3-
<LangVersion>latest</LangVersion>
4-
<Nullable>enable</Nullable>
5-
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
6-
<EnableNETAnalyzers>True</EnableNETAnalyzers>
7-
<AnalysisLevel>latest</AnalysisLevel>
8-
<IsPackable>false</IsPackable>
9-
</PropertyGroup>
10-
<ItemGroup>
11-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
12-
<PrivateAssets>all</PrivateAssets>
13-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14-
</PackageReference>
15-
<PackageReference Include="Meziantou.Analyzer" Version="1.0.702">
16-
<PrivateAssets>all</PrivateAssets>
17-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18-
</PackageReference>
19-
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.2.32">
20-
<PrivateAssets>all</PrivateAssets>
21-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
22-
</PackageReference>
23-
<PackageReference Include="AsyncFixer" Version="1.6.0">
24-
<PrivateAssets>all</PrivateAssets>
25-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
26-
</PackageReference>
27-
</ItemGroup>
2+
<PropertyGroup>
3+
<LangVersion>latest</LangVersion>
4+
<Nullable>enable</Nullable>
5+
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
6+
<EnableNETAnalyzers>True</EnableNETAnalyzers>
7+
<AnalysisLevel>latest</AnalysisLevel>
8+
<IsPackable>false</IsPackable>
9+
</PropertyGroup>
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
</PackageReference>
15+
<PackageReference Include="Meziantou.Analyzer" Version="1.0.702">
16+
<PrivateAssets>all</PrivateAssets>
17+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18+
</PackageReference>
19+
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.2.32">
20+
<PrivateAssets>all</PrivateAssets>
21+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
22+
</PackageReference>
23+
<PackageReference Include="AsyncFixer" Version="1.6.0">
24+
<PrivateAssets>all</PrivateAssets>
25+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
26+
</PackageReference>
27+
</ItemGroup>
2828
</Project>

PackageInstaller.Core.Services.Tests/AndroidDeviceProviderTests.cs

+10-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public async Task GetAllInstalledDistributionsAsync_ShouldReturnEmptyListAsync()
1717

1818
var adp = new AndroidDeviceProvider(adb);
1919

20-
var list = await adp.GetAllInstalledDistributionsAsync("");
20+
var list = await adp.GetAllInstalledDistributionsAsync("").ConfigureAwait(false);
2121

2222
list.Alerts.Should().BeEmpty();
2323
list.InstalledDistributions.Should().BeEmpty();
@@ -32,8 +32,9 @@ public async Task GetAllInstalledDistributionsAsync_ShouldReturnAdbWarningAsync(
3232
var adp = new AndroidDeviceProvider(adb);
3333

3434
var list = await adp.GetAllInstalledDistributionsAsync(
35-
AndroidDeviceProvider.APK_FILE_EXTENSION
36-
);
35+
AndroidDeviceProvider.APK_FILE_EXTENSION
36+
)
37+
.ConfigureAwait(false);
3738

3839
list.InstalledDistributions.Should().BeEmpty();
3940
list.Alerts.Should().HaveCount(1);
@@ -49,8 +50,9 @@ public async Task GetAllInstalledDistributionsAsync_ShouldReturnNoDevicesFoundWa
4950
var adp = new AndroidDeviceProvider(adb);
5051

5152
var list = await adp.GetAllInstalledDistributionsAsync(
52-
AndroidDeviceProvider.APK_FILE_EXTENSION
53-
);
53+
AndroidDeviceProvider.APK_FILE_EXTENSION
54+
)
55+
.ConfigureAwait(false);
5456

5557
list.InstalledDistributions.Should().BeEmpty();
5658
list.Alerts.Should().HaveCount(1);
@@ -97,8 +99,9 @@ Version androidVersion
9799
var adp = new AndroidDeviceProvider(adb);
98100

99101
var list = await adp.GetAllInstalledDistributionsAsync(
100-
AndroidDeviceProvider.APK_FILE_EXTENSION
101-
);
102+
AndroidDeviceProvider.APK_FILE_EXTENSION
103+
)
104+
.ConfigureAwait(false);
102105

103106
list.InstalledDistributions.Should().HaveCount(1);
104107
list.InstalledDistributions

PackageInstaller.Core.Services.Tests/WsaProviderTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public async Task GetAllInstalledDistributionsAsync_ShouldReturnEmptyListAsync()
1818

1919
var wsa = new WsaProvider(wsaClient);
2020

21-
var list = await wsa.GetAllInstalledDistributionsAsync("");
21+
var list = await wsa.GetAllInstalledDistributionsAsync("").ConfigureAwait(false);
2222

2323
list.Alerts.Should().BeEmpty();
2424
list.InstalledDistributions.Should().BeEmpty();
@@ -39,7 +39,7 @@ bool isWsaInstalled
3939

4040
var wsa = new WsaProvider(wsaClient);
4141

42-
var list = await wsa.GetAllInstalledDistributionsAsync(extension);
42+
var list = await wsa.GetAllInstalledDistributionsAsync(extension).ConfigureAwait(false);
4343

4444
list.Alerts.Should().NotBeEmpty();
4545
list.InstalledDistributions.Should().BeEmpty();
@@ -55,7 +55,7 @@ public async Task GetAllInstalledDistributionsAsync_ShouldReturnWsaDeviceAsync()
5555

5656
var wsa = new WsaProvider(wsaClient);
5757

58-
var list = await wsa.GetAllInstalledDistributionsAsync("");
58+
var list = await wsa.GetAllInstalledDistributionsAsync("").ConfigureAwait(false);
5959

6060
list.Alerts.Should().BeEmpty();
6161
list.InstalledDistributions.Should().HaveCount(1);

PackageInstaller.Core.Services.Tests/WslProviderTests.cs

+24-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bool isWsaInstalled
2424

2525
var wsl = new WslProvider(wslApi);
2626

27-
var list = await wsl.GetAllInstalledDistributionsAsync(extension);
27+
var list = await wsl.GetAllInstalledDistributionsAsync(extension).ConfigureAwait(false);
2828

2929
list.Alerts.Should().NotBeEmpty();
3030
list.InstalledDistributions.Should().BeEmpty();
@@ -35,9 +35,24 @@ public async Task GetAllInstalledDistributionsAsync_ShouldReturnWslDeviceAsync()
3535
{
3636
var devices = new DistroInfo[]
3737
{
38-
new DistroInfo() { DistroName = "docker-desktop-data", IsDefault = false, WslVersion = 2, },
39-
new DistroInfo() { DistroName = "docker-desktop", IsDefault = false, WslVersion = 2, },
40-
new DistroInfo() { DistroName = "Ubuntu 40.2", IsDefault = false, WslVersion = 2, },
38+
new DistroInfo()
39+
{
40+
DistroName = "docker-desktop-data",
41+
IsDefault = false,
42+
WslVersion = 2,
43+
},
44+
new DistroInfo()
45+
{
46+
DistroName = "docker-desktop",
47+
IsDefault = false,
48+
WslVersion = 2,
49+
},
50+
new DistroInfo()
51+
{
52+
DistroName = "Ubuntu 40.2",
53+
IsDefault = false,
54+
WslVersion = 2,
55+
},
4156
};
4257

4358
var wslApi = A.Fake<IWslApi>();
@@ -48,17 +63,18 @@ public async Task GetAllInstalledDistributionsAsync_ShouldReturnWslDeviceAsync()
4863

4964
var wsl = new WslProvider(wslApi);
5065

51-
var list = await wsl.GetAllInstalledDistributionsAsync("");
66+
var list = await wsl.GetAllInstalledDistributionsAsync("").ConfigureAwait(false);
5267

5368
list.Alerts.Should().BeEmpty();
5469
list.InstalledDistributions.Should().HaveCount(1);
5570
}
5671

57-
5872
private static readonly object[] DEVICES_TEST_SOURCES = new[] { Array.Empty<DistroInfo>(), };
5973

6074
[TestCaseSource(nameof(DEVICES_TEST_SOURCES))]
61-
public async Task GetAllInstalledDistributionsAsync_ShouldReturnNoDistrosInstalledAsync(DistroInfo[] distroList)
75+
public async Task GetAllInstalledDistributionsAsync_ShouldReturnNoDistrosInstalledAsync(
76+
DistroInfo[] distroList
77+
)
6278
{
6379
var wslApi = A.Fake<IWslApi>();
6480
var msg = "msg";
@@ -68,7 +84,7 @@ public async Task GetAllInstalledDistributionsAsync_ShouldReturnNoDistrosInstall
6884

6985
var wsl = new WslProvider(wslApi);
7086

71-
var list = await wsl.GetAllInstalledDistributionsAsync("");
87+
var list = await wsl.GetAllInstalledDistributionsAsync("").ConfigureAwait(false);
7288

7389
list.Alerts.Should().HaveCount(1);
7490
list.InstalledDistributions.Should().BeEmpty();

PackageInstaller.Core/ModelViews/ActionExecutionViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ await packageManager
220220
.DowngradeAsync(distroName, packageFilePath, progressController)
221221
.ConfigureAwait(false);
222222
default:
223-
throw new ArgumentOutOfRangeException();
223+
throw new ArgumentOutOfRangeException(null, $"Unknown action {_selectedAction}");
224224
}
225225
}
226226

0 commit comments

Comments
 (0)