Skip to content

Commit f2eb3b7

Browse files
committed
Add ProjectLoader tests
1 parent 1f38037 commit f2eb3b7

18 files changed

+250
-12
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ jobs:
4848
uses: actions/[email protected]
4949
with:
5050
source-url: https://nuget.pkg.github.com/xt0rted/index.json
51-
dotnet-version: 6.0.x
51+
dotnet-version: |
52+
3.1.x
53+
5.0.x
54+
6.0.x
5255
env:
5356
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5457

5558
- run: dotnet tool restore
5659

5760
- run: dotnet r build
5861

59-
- run: dotnet r test --if-present
62+
- run: dotnet r test
6063

6164
- run: dotnet r pack -- --version-suffix ${{ env.VERSION_SUFFIX }}
6265

.github/workflows/release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ jobs:
3030
uses: actions/[email protected]
3131
with:
3232
source-url: https://nuget.pkg.github.com/xt0rted/index.json
33-
dotnet-version: 6.0.x
33+
dotnet-version: |
34+
3.1.x
35+
5.0.x
36+
6.0.x
3437
env:
3538
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3639

@@ -44,7 +47,7 @@ jobs:
4447

4548
- run: dotnet r build
4649

47-
- run: dotnet r test --if-present
50+
- run: dotnet r test
4851

4952
- run: dotnet r pack
5053

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ node_modules/
301301
*.dsw
302302
*.dsp
303303

304-
# Visual Studio 6 technical files
304+
# Visual Studio 6 technical files
305305
*.ncb
306306
*.aps
307307

@@ -396,3 +396,6 @@ FodyWeavers.xsd
396396

397397
# JetBrains Rider
398398
*.sln.iml
399+
400+
# Verify snapshots
401+
*.received.*

global.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"prebuild": "dotnet r clean",
1010
"build": "dotnet build",
1111
"test": "dotnet test --no-build --logger \"trx\" --results-directory \"./.coverage\"",
12+
"test:31": "dotnet r test -- --framework netcoreapp3.1",
13+
"test:5": "dotnet r test -- --framework net5.0",
14+
"test:6": "dotnet r test -- --framework net6.0",
1215
"pack": "dotnet pack --no-build --output ./artifacts",
1316

1417
"build:release": "dotnet r build -- --configuration Release",

run-script.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1919
README.md = README.md
2020
EndProjectSection
2121
EndProject
22+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "test\Tests.csproj", "{0A834097-CB5A-4E14-845D-1AA0E8EBEA29}"
23+
EndProject
2224
Global
2325
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2426
Debug|Any CPU = Debug|Any CPU
@@ -29,6 +31,10 @@ Global
2931
{AEF0FF86-3911-45DE-9291-EDC8E96329F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
3032
{AEF0FF86-3911-45DE-9291-EDC8E96329F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
3133
{AEF0FF86-3911-45DE-9291-EDC8E96329F4}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{0A834097-CB5A-4E14-845D-1AA0E8EBEA29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{0A834097-CB5A-4E14-845D-1AA0E8EBEA29}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{0A834097-CB5A-4E14-845D-1AA0E8EBEA29}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{0A834097-CB5A-4E14-845D-1AA0E8EBEA29}.Release|Any CPU.Build.0 = Release|Any CPU
3238
EndGlobalSection
3339
GlobalSection(SolutionProperties) = preSolution
3440
HideSolutionNode = FALSE

src/ProjectLoader.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,20 @@ public class ProjectLoader
5353
{
5454
var json = await File.ReadAllTextAsync(jsonPath);
5555

56-
return JsonSerializer.Deserialize<Project>(
57-
json,
58-
new JsonSerializerOptions
59-
{
60-
PropertyNameCaseInsensitive = true,
61-
ReadCommentHandling = JsonCommentHandling.Skip,
62-
});
56+
try
57+
{
58+
var globalJson = JsonSerializer.Deserialize<Project>(json, new JsonSerializerOptions
59+
{
60+
PropertyNameCaseInsensitive = true,
61+
ReadCommentHandling = JsonCommentHandling.Skip,
62+
});
63+
64+
return globalJson;
65+
}
66+
catch
67+
{
68+
return null;
69+
}
6370
}
6471

6572
private static Dictionary<string, string?> LoadScripts(Project project)

src/run-script.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
<RootNamespace>RunScript</RootNamespace>
45
<OutputType>Exe</OutputType>
56
<DebugSymbols>true</DebugSymbols>
67
<DebugType>embedded</DebugType>

test/.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.cs]
2+
# RCS1046: Asynchronous method name should end with 'Async'
3+
dotnet_diagnostic.RCS1046.severity = none
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
Scripts: {
3+
test: echo "dir1" && exit 1
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
Scripts: {
3+
test: echo "dir1" && exit 1
4+
}
5+
}

0 commit comments

Comments
 (0)