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

NotInMaps false positive #99

Open
ivan-coder opened this issue Apr 30, 2024 · 3 comments
Open

NotInMaps false positive #99

ivan-coder opened this issue Apr 30, 2024 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@ivan-coder
Copy link

We started using the plugin a few days ago, but shortly after implementation, we encountered erratic failures in our unit test suite. One test, responsible for validating scene references across our prefabs, began exhibiting inconsistent behavior.

Our test looks like this:

            if (scene.State == SceneReferenceState.Unsafe)
            {
                Debug.LogError($"There's a problem with the scene settings. Reason: '{scene.UnsafeReason}'");
            }

So while all works well in editor, turns out that the unit tests running on a remote self-hosted linux machine fail sometimes.
Investigating a bit, it seems that the SceneDataMap was sometimes not generated by the time the test was trying to run, thus failing with "NotInMaps" message.

We added this to make sure the maps were generated before running any tests, and it seems to be working fine now.

        [SetUp]
        public void SetUpTests()
        {
            SceneDataMapsGenerator.Run(false);
        }

However, we're left wondering if this behavior is expected or if others have encountered similar challenges when running tests through GitHub Actions.

@Ale1
Copy link
Contributor

Ale1 commented Apr 30, 2024

It could be caused by github actions running unity with -batchmode flag.
(side note: Its infuriating that unity's batchmode initializes things in different order to editor enviroment... )

@ivan-coder . You could test locally on your computer running the unit tests in batchmode to check if same error pops up.
Btw, have you tried [OneTimeSetup] instead for your workaround? It seems like regenerating the maps on [SetUp] would be overkill.

@starikcetin
Copy link
Owner

I think @Ale1 is right. In my previous job we have encountered situations where the build hooks were not executed when the editor is run in batchmode. We instead ran our builds without batchmode and manually called editor quit in the code after we are done.

In this case, since the map generator runs in a pre-build hook, it might not be running in batchmode.

@starikcetin starikcetin added the bug Something isn't working label Apr 30, 2024
@starikcetin
Copy link
Owner

starikcetin commented Apr 30, 2024

That being said, what you did in the setup method is correct. So you can continue using it also. Just be careful about testing in players, then you would want to call the generator with true instead, since you would want file outputs in that case.

@starikcetin starikcetin added documentation Improvements or additions to documentation and removed bug Something isn't working labels May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants