Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allure-xunit: exit code 1 if Harmony patching fails #441

Closed
1 of 3 tasks
delatrie opened this issue Dec 21, 2023 · 0 comments · Fixed by #455
Closed
1 of 3 tasks

Allure-xunit: exit code 1 if Harmony patching fails #441

delatrie opened this issue Dec 21, 2023 · 0 comments · Fixed by #455

Comments

@delatrie
Copy link
Contributor

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:

Other information

Exit code 1 is forced by LogError here:

logger.LogError(
"Unable to patch {0}'s {1}: {2}",
testRunnerType.Name,
ctor.ToString(),
e.ToString()
);

@delatrie delatrie added the bug label Dec 21, 2023
@delatrie delatrie self-assigned this Dec 21, 2023
@delatrie delatrie changed the title Allure-xunit: Allure-xunit: exit code 1 if Harmony patching fails Dec 21, 2023
@delatrie delatrie removed their assignment Mar 26, 2024
delatrie pushed a commit that referenced this issue Mar 28, 2024
* #441 - Fix exit code 1 if Harmony patching failled

Use LogWarning instead LogError
Change codestyle - filescoped namespace, explicit modifiers for better code readability

* #441 - Fix exit code 1 if Harmony patching failled

Review fixes
@delatrie delatrie linked a pull request Apr 1, 2024 that will close this issue
2 tasks
@delatrie delatrie closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant