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

Add standalone testmode support #219

Merged
merged 11 commits into from
Apr 21, 2023
Merged

Conversation

timcassell
Copy link
Contributor

@timcassell timcassell commented Apr 14, 2023

Resolves #208.

Changes

testMode: standalone now builds the player with tests (StandaloneLinux64 or StandaloneWindows64) and runs it directly. This is useful for running tests in the IL2CPP runtime (of course it's not restricted to IL2CPP).

Checklist

  • Read the contribution guide and accept the code of conduct
  • Readme (updated or not needed)
  • Tests (added, updated or not needed)

Additional Info

Requires Unity 2019.2 or newer and Test Framework 1.0.15 or newer.

testmode: all still only runs editmode and playmode (so as to not break existing users).

I got a working test run here. I was unable to test it on a Windows runner due to #200.

@github-actions
Copy link

Cat Gif

@timcassell
Copy link
Contributor Author

I'm not sure why the first test is failing, but I fixed the other tests I added.

@timcassell
Copy link
Contributor Author

@webbertakken @davidmfinol Can you please take a look?

Copy link
Member

@webbertakken webbertakken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Though I have little context about the specifics.

Can you confirm both?

  • This works
  • This does not break previous flows

dist/steps/run_tests.sh Outdated Show resolved Hide resolved
@webbertakken
Copy link
Member

I'm also seeing some errors in the workflows:

-----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/UnityEngine.TestRunner.dll
Microsoft (R) Visual C# Compiler version 2.9.1.65535 (9d34608e)
Copyright (C) Microsoft Corporation. All rights reserved.

Library/PackageCache/[email protected]/UnityEngine.TestRunner/NUnitExtensions/Runner/UnityLogCheckDelegatingCommand.cs(115,57): error CS0246: The type or namespace name 'TestMustExpectAllLogsAttribute' could not be found (are you missing a using directive or an assembly reference?)
Library/PackageCache/[email protected]/UnityEngine.TestRunner/NUnitExtensions/Runner/UnityLogCheckDelegatingCommand.cs(124,63): error CS0246: The type or namespace name 'TestMustExpectAllLogsAttribute' could not be found (are you missing a using directive or an assembly reference?)
Library/PackageCache/[email protected]/UnityEngine.TestRunner/NUnitExtensions/Runner/UnityLogCheckDelegatingCommand.cs(136,65): error CS0246: The type or namespace name 'TestMustExpectAllLogsAttribute' could not be found (are you missing a using directive or an assembly reference?)
-----CompilerOutput:-stderr----------
-----EndCompilerOutput---------------
- Finished compile Library/ScriptAssemblies/UnityEngine.TestRunner.dll
Library/PackageCache/[email protected]/UnityEngine.TestRunner/NUnitExtensions/Runner/UnityLogCheckDelegatingCommand.cs(115,57): error CS0246: The type or namespace name 'TestMustExpectAllLogsAttribute' could not be found (are you missing a using directive or an assembly reference?)
Library/PackageCache/[email protected]/UnityEngine.TestRunner/NUnitExtensions/Runner/UnityLogCheckDelegatingCommand.cs(124,63): error CS0246: The type or namespace name 'TestMustExpectAllLogsAttribute' could not be found (are you missing a using directive or an assembly reference?)
Library/PackageCache/[email protected]/UnityEngine.TestRunner/NUnitExtensions/Runner/UnityLogCheckDelegatingCommand.cs(136,65): error CS0246: The type or namespace name 'TestMustExpectAllLogsAttribute' could not be found (are you missing a using directive or an assembly reference?)
[ScriptCompilation] Recompiling all scripts because: Reload of assemblies failed
- Starting compile Library/ScriptAssemblies/UnityEngine.TestRunner.dll

https://github.com/game-ci/unity-test-runner/actions/runs/4711881330/jobs/8433363879?pr=219#step:4:682

Not sure if they were introduced in this PR or not, but we can't merge if we're blind.

@timcassell
Copy link
Contributor Author

timcassell commented Apr 19, 2023

I'm also seeing some errors in the workflows:

That's weird. The tests passed when I ran them in my fork. https://github.com/timcassell/unity-test-runner/actions/runs/4748246522
Only the first test was failing there (I have no knowledge of ESLINT).

@timcassell
Copy link
Contributor Author

Can you confirm both?

  • This works
  • This does not break previous flows

Yes, details under additional info in the PR description.

@timcassell
Copy link
Contributor Author

@webbertakken I think those failures are Unity's fault (the only change in the project in those workflows is the TestFramework version update). I changed the workflows to use 2019.4.40f1 which seems more stable.

About the other failing test, any idea what this is about?

output

Run yarn lint
yarn run v1.22.19
$ prettier --check "src/**/*.{js,ts}" && eslint src --ext .js,.ts --max-warnings=0
Checking formatting...
All matched files use Prettier code style!

Oops! Something went wrong! :(

ESLint: 8.38.0

/home/runner/work/unity-test-runner/unity-test-runner/node_modules/eslint-plugin-github/lib/rules/role-supports-aria-props.js:12
  key.attributes = key.attributes?.filter(attribute => !('constraints' in attribute))
                                  ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:9[63](https://github.com/timcassell/unity-test-runner/actions/runs/4748493372/jobs/8434746160#step:5:64):27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/runner/work/unity-test-runner/unity-test-runner/node_modules/eslint-plugin-github/lib/index.js:21:33)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 2.

@timcassell
Copy link
Contributor Author

Looking at vercel/next.js#38530 with the same error, it appears that syntax requires node 14 or higher. The test is using node-version: 12.x. Can that be updated, or is 12.x required for some reason?

@webbertakken
Copy link
Member

Tests seem to be passing. Still looks good to me.

Perhaps Andrew or David could have another look and merge it if they're also on board.

Copy link
Member

@davidmfinol davidmfinol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@davidmfinol davidmfinol merged commit 31086d9 into game-ci:main Apr 21, 2023
@joaoborks
Copy link

I'm using the unity-test-runner version 2.1.1 that should include this feature, but I'm getting the error:

Run game-ci/unity-test-runner@v[2](https://github.com/mygamedevtools/scene-loader/actions/runs/5396165109/jobs/9799475943#step:4:2).1.1
  with:
    projectPath: ./
    testMode: standalone
    artifactsPath: standalone-artifacts
    githubToken: ***
    checkName: standalone Test Results
    coverageOptions: generateAdditionalMetrics;assemblyFilters:+MyGameDevTools.SceneLoading
    unityVersion: auto
    useHostNetwork: false
  env:
    UNITY_LICENSE: ***
Error: Invalid testMode standalone

@timcassell
Copy link
Contributor Author

timcassell commented Jun 28, 2023

@joaoborks A new version with this feature has not been released yet. You can try it with

game-ci/unity-test-runner@main

or for the specific commit

game-ci/unity-test-runner@31086d985910613d75c32ba965f657df9c298820

Also note that your coverageOptions won't do anything with testMode: standalone.

@joaoborks
Copy link

Thanks @timcassell, it worked with the commit hash. Is there any ETA on the new release version?

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

Successfully merging this pull request may close these issues.

Add standalone testMode
4 participants