Allure-xunit: exit code 1 if Harmony patching fails
delatrie opened this issue · 0 comments
delatrie commented
I'm submitting a ...
- bug report
- feature request
- support request => Please do not submit support request here, see note at the top of this template.
What is the current behavior?
If XunitTestRunners' constructor patching with Harmony fails (e.g., #410, #434), xunit returns exit code 1 once finished. It doesn't affect test execution though, except that:
- non-pre-enumerated arguments of theories aren't included in the report
- selective run with
testplan.json
doesn't work
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
Run allure-xunit under net8.0. The following error is logged:
[xUnit.net 00:00:00.[23](https://github.com/qameta/allure-start/actions/runs/7290149114/job/19866373458#step:5:24)] Unable to patch XunitTestRunner's Void .ctor(Xunit.Abstractions.ITest, Xunit.Sdk.IMessageBus, System.Type, System.Object[], System.Reflection.MethodInfo, System.Object[], System.String, System.Collections.Generic.IReadOnlyList`1[Xunit.Sdk.BeforeAfterTestAttribute], Xunit.Sdk.ExceptionAggregator, System.Threading.CancellationTokenSource): System.TypeInitializationException: The type initializer for 'MonoMod.Utils.DMDEmitDynamicMethodGenerator' threw an exception.
---> System.InvalidOperationException: Cannot find returnType fieeld on DynamicMethod
at MonoMod.Utils.DMDEmitDynamicMethodGenerator..cctor()
--- End of inner exception stack trace ---
at MonoMod.Utils.DMDEmitDynamicMethodGenerator.GenerateCore(DynamicMethodDefinition dmd, Object context)
at MonoMod.Utils.DMDGenerator`1.Generate(DynamicMethodDefinition dmd, Object context)
at MonoMod.Utils.DynamicMethodDefinition.Generate(Object context)
at MonoMod.Utils.DynamicMethodDefinition.Generate()
at HarmonyLib.MethodPatcher.CreateReplacement(Dictionary`2& finalInstructions)
at HarmonyLib.PatchFunctions.UpdateWrapper(MethodBase original, PatchInfo patchInfo)
at HarmonyLib.PatchProcessor.Patch()
at HarmonyLib.Harmony.Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler, HarmonyMethod finalizer)
at Allure.XUnit.AllureXunitPatcher.PatchXunitTestRunnerCtors(Harmony patcher)
[xUnit.net 00:00:00.[24](https://github.com/qameta/allure-start/actions/runs/7290149114/job/19866373458#step:5:25)] No constructors of XunitTestRunner were pathched. Some theories may miss their parameters in the report
While the tests are executed and Allure result files are generated, the process returns exit code 1. That causes a CI workflow to fail.
What is the expected behavior?
A warning is shown instead of the error. The process returns exit code 0.
Please tell us about your environment:
- Allure version: 2.25.0
- Test framework: xUnit.net@2.6.3
- Allure adaptor: allure-xunit@2.11.0
Other information
Exit code 1 is forced by LogError
here:
allure-csharp/Allure.XUnit/AllureXunitPatcher.cs
Lines 73 to 78 in 7299f1a