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

Unit test will not run on the single module build #306

Closed
kuqin12 opened this issue Aug 23, 2022 · 2 comments
Closed

Unit test will not run on the single module build #306

kuqin12 opened this issue Aug 23, 2022 · 2 comments
Labels
new Issue not yet reviewed

Comments

@kuqin12
Copy link
Contributor

kuqin12 commented Aug 23, 2022

Describe the bug
When the user specifies to build and execute a single unit test by issuing BUILDMODULE=**.inf (as documented in edk2), the actual unit test will not end up being executed.

This is because the "BUILDMODULE" flag will disable the post build plugins from running here and unit tests are executed as part of post build plugins: https://github.com/tianocore/edk2/blob/master/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py#L30.

To Reproduce
Steps to reproduce the behavior:

  1. Use any package that supports unit test dsc.
  2. Issue the "NOOPT" target and "BUILDMODULE" to specify a single module.
  3. Notice that the unit test not being run.

Expected behavior
The single unit test will run.

Execution environment
Windows.

@kuqin12 kuqin12 added the new Issue not yet reviewed label Aug 23, 2022
@Javagedes
Copy link
Contributor

@kuqin12 The reason we disable post build plugins from running is that we "promise" plugins that the entire project is built. By setting BUILDMODULE, we are no longer building the entire project, which may cause some plugins (that expect an entire build project) to fail. Due to this, we disable all post build plugins.

My suggestion here is to edit the HostUnitTestCompilerPlugin to run the plugin itself if BUILDMODULE is set. ICiBuildPlugins already have all the information needed to do this.

Starting at https://github.com/microsoft/mu_basecore/blob/877f781ada3b2b56c7397d02f30dae798f9ab5d9/.pytool/Plugin/HostUnitTestCompilerPlugin/HostUnitTestCompilerPlugin.py#L146

You can add the following code. I've already verified in successfully executes host based tests and also catches any host based test failures similar to if running all host based tests.

# Run the tests manually if only building a single module, as it will be skipped by stuart_ci_build
mod = environment.GetValue("BUILDMODULE")
if (mod is not None and len(mod.strip()) > 0):
    for plugin in PLM.GetPluginsOfClass(IUefiBuildPlugin):
        if plugin.descriptor['scope'] == 'host-based-test':
            if plugin.Obj.do_post_build(uefiBuilder) != 0:
                tc.SetFailed("Compile failed for {0}".format(packagename), "Compile_FAILED")
                tc.LogStdError("{0} Compile failed with error code {1} ".format(AP_Path, ret))
                return 1

If @kuqin12 and @spbrogan are okay with it, I can put up a PR in MU_BASECORE with the change.

@Javagedes
Copy link
Contributor

Resolved in MU_BASECORE via microsoft/mu_basecore#219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new Issue not yet reviewed
Projects
None yet
Development

No branches or pull requests

2 participants