-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
* some setup * make it build and execute without AOT * at this moment - i dont know * minimal assembly references * bump packages and then it does not work still... * do it iteratively * move pieces around * make it work with executable assembly! * omg it works. * use existing local machine table name * record stack traces * remove package versions * refactor dependencies * YES!!! YES!!! YES!!! YES!!! YES!!! YES!!! YES!!! * fix dbstring global namespace + adjust test for DbString * and run tests for new proj * last minute review * rollback package updates (they break tests) * remove coverlet collector * use sln * internal visible to * try specific routes * dont build it * try with ubuntu agents * rollback CI\CD + create another for integrations on ubuntu * fix for dbstring + rename CI * debug test * fix naming * try publish directory * move item group * get logs from build * maybe slash can fix it? * remove detailed verbosity * . * always? * test on wsl * build only test proj * move it to integration directly * give me logs * dont use copy at all * cleanup debug CI * move to csproj
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Integration Tests | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # depth is needed for nbgv | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: | | ||
6.0.x | ||
8.0.x | ||
include-prerelease: true | ||
|
||
- name: Build | ||
run: dotnet build Dapper.AOT.sln -c Debug | ||
|
||
- name: E2E Tests | ||
run: dotnet test test/Dapper.AOT.Test.Integration/Dapper.AOT.Test.Integration.csproj --no-build --verbosity normal -c Debug |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net8.0;net6.0;net48</TargetFrameworks> | ||
<RootNamespace>Dapper.AOT.Test.Integration.Executables</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Dapper" Condition="'$(TargetFramework)' == 'net6.0'" /> | ||
<PackageReference Include="Dapper.StrongName" Condition="'$(TargetFramework)'=='net48'" /> | ||
<PackageReference Include="Dapper" Condition="'$(TargetFramework)' == 'net8.0'" /> | ||
|
||
<ProjectReference Include="..\..\src\Dapper.AOT.Analyzers\Dapper.AOT.Analyzers.csproj" /> | ||
<ProjectReference Include="..\..\src\Dapper.AOT\Dapper.AOT.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using Dapper.AOT.Test.Integration.Executables.Recording; | ||
using Dapper.CodeAnalysis; | ||
|
||
namespace Dapper.AOT.Test.Integration.Executables; | ||
|
||
public class ExceptedCodeInterceptorRecorder<TExecutable> : IInterceptorRecorder | ||
{ | ||
readonly string expectedFileName; | ||
|
||
public ExceptedCodeInterceptorRecorder(string expectedFileName) | ||
{ | ||
this.expectedFileName = expectedFileName ?? throw new ArgumentNullException(nameof(expectedFileName)); | ||
} | ||
|
||
public bool WasCalled { get; private set; } | ||
public string? Diagnostics { get; private set; } | ||
|
||
public void Record() | ||
{ | ||
WasCalled = true; | ||
var diagnostics = new StringBuilder(); | ||
|
||
var stackTrace = new StackTrace(fNeedFileInfo: true); | ||
var recentFrames = stackTrace.GetFrames().Take(15).ToList(); // we dont need everything | ||
|
||
var userCodeFrameIndex = recentFrames.FindIndex(frame => | ||
frame.GetFileName()?.Contains(expectedFileName) == true && frame.GetMethod()?.Name.Equals(nameof(IExecutable<TExecutable>.Execute)) == true); | ||
if (userCodeFrameIndex == -1) | ||
{ | ||
diagnostics.AppendLine("- User code execution is not found"); | ||
} | ||
|
||
var dapperInterceptionFrameIndex = recentFrames.FindIndex(frame => | ||
frame.GetFileName()?.Contains(".generated.cs") == true && frame.GetFileName()?.Contains(nameof(DapperInterceptorGenerator)) == true); | ||
if (dapperInterceptionFrameIndex == -1) | ||
{ | ||
diagnostics.AppendLine("- User code execution is not found"); | ||
} | ||
|
||
if (userCodeFrameIndex < dapperInterceptionFrameIndex) | ||
{ | ||
diagnostics.AppendLine("- User code call should be higher (executed before) on the stack trace than intercepted code"); | ||
} | ||
|
||
Diagnostics = diagnostics.ToString(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System.Data; | ||
|
||
namespace Dapper.AOT.Test.Integration.Executables; | ||
|
||
public interface IExecutable<T> | ||
{ | ||
public T Execute(IDbConnection connection); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Dapper.AOT.Test.Integration.Executables.Models; | ||
|
||
public class DbStringPoco | ||
{ | ||
public const string TableName = "dbStringPoco"; | ||
|
||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
Check warning on line 8 in test/Dapper.AOT.Test.Integration.Executables/Models/DbStringPoco.cs GitHub Actions / build
Check warning on line 8 in test/Dapper.AOT.Test.Integration.Executables/Models/DbStringPoco.cs GitHub Actions / build
Check warning on line 8 in test/Dapper.AOT.Test.Integration.Executables/Models/DbStringPoco.cs GitHub Actions / build
Check warning on line 8 in test/Dapper.AOT.Test.Integration.Executables/Models/DbStringPoco.cs GitHub Actions / build
Check warning on line 8 in test/Dapper.AOT.Test.Integration.Executables/Models/DbStringPoco.cs GitHub Actions / build
Check warning on line 8 in test/Dapper.AOT.Test.Integration.Executables/Models/DbStringPoco.cs GitHub Actions / build
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Dapper.AOT.Test.Integration.Executables.Recording; | ||
|
||
public interface IInterceptorRecorder | ||
{ | ||
/// <summary> | ||
/// returns true if expected interception was called | ||
/// </summary> | ||
public bool WasCalled { get; } | ||
|
||
/// <summary> | ||
/// Returns diagnostics of recording | ||
/// </summary> | ||
public string? Diagnostics { get; } | ||
|
||
/// <summary> | ||
/// Is executed in the interception | ||
/// </summary> | ||
public void Record(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Dapper.AOT.Test.Integration.Executables.Recording; | ||
|
||
public static class InterceptorRecorderResolver | ||
{ | ||
static IInterceptorRecorder? _recorder; | ||
|
||
public static IInterceptorRecorder? Resolve() => _recorder; | ||
public static void Register(IInterceptorRecorder? recorder) => _recorder = recorder; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Data; | ||
using System.Linq; | ||
using Dapper.AOT.Test.Integration.Executables.Models; | ||
|
||
namespace Dapper.AOT.Test.Integration.Executables.UserCode; | ||
|
||
[DapperAot] | ||
public class DbStringUsage : IExecutable<DbStringPoco> | ||
{ | ||
public DbStringPoco Execute(IDbConnection connection) | ||
{ | ||
var results = connection.Query<DbStringPoco>( | ||
$"select * from {DbStringPoco.TableName} where name = @name", | ||
new | ||
{ | ||
name = new DbString | ||
{ | ||
Value = "my-dbString" | ||
} | ||
}); | ||
return results.First(); | ||
} | ||
} |