mirror of
https://github.com/game-ci/unity-test-runner.git
synced 2026-02-08 23:09:05 +08:00
Code Coverage Support (#182)
* Added basic framework for enable code coverage * Added basic coverage results building and combination * fixed ENABLE_CODE_COVERAGE to be `true` or `false` * Added code coverage project to manifest * Updated to add more tests for code coverage build * Updated coverage parameter documentation * Fixed small syntax error * Enabled code coverage flag for code coverage tests * Fixed error in test file build * Updated project run settings * Fixed error when creating combined code coverage results * Updated testing workflows * updated test workflows * Updated parameters and added tests * Updated tests and bash script for running * Updated run_tests.sh script to simplfy some parameters * Updated run_tests to remove incorrect ';' * Updated run_tests script * Fixed small syntax error * Fixed for loop in run_tests.sh * Updated run_tests syntax error for '=' operator * Fixed runTests variable assignment * Fixed parameters for running tests via bash * Corrected bash arguments * Updated test cases in main.yml * Updated parameter names and default values for code coverage * Fixed broken paths for coverage results upload in main.yml * Corrected names of coverage results artifacts
This commit is contained in:
@@ -11,6 +11,7 @@ const Docker = {
|
||||
projectPath,
|
||||
customParameters,
|
||||
testMode,
|
||||
coverageOptions,
|
||||
artifactsPath,
|
||||
useHostNetwork,
|
||||
sshAgent,
|
||||
@@ -23,6 +24,9 @@ const Docker = {
|
||||
if (!existsSync(githubHome)) mkdirSync(githubHome);
|
||||
const githubWorkflow = path.join(runnerTemporaryPath, '_github_workflow');
|
||||
if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow);
|
||||
const testPlatforms = (
|
||||
testMode === 'all' ? ['playmode', 'editmode', 'COMBINE_RESULTS'] : [testMode]
|
||||
).join(';');
|
||||
|
||||
const command = `docker run \
|
||||
--workdir /github/workspace \
|
||||
@@ -35,7 +39,9 @@ const Docker = {
|
||||
--env UNITY_VERSION="${editorVersion}" \
|
||||
--env PROJECT_PATH="${projectPath}" \
|
||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||
--env TEST_MODE="${testMode}" \
|
||||
--env TEST_PLATFORMS="${testPlatforms}" \
|
||||
--env COVERAGE_OPTIONS="${coverageOptions}" \
|
||||
--env COVERAGE_RESULTS_PATH="CodeCoverage" \
|
||||
--env ARTIFACTS_PATH="${artifactsPath}" \
|
||||
--env GITHUB_REF \
|
||||
--env GITHUB_SHA \
|
||||
|
||||
@@ -19,6 +19,7 @@ const Input = {
|
||||
const rawProjectPath = getInput('projectPath') || '.';
|
||||
const customParameters = getInput('customParameters') || '';
|
||||
const testMode = (getInput('testMode') || 'all').toLowerCase();
|
||||
const coverageOptions = getInput('coverageOptions') || '';
|
||||
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
|
||||
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
|
||||
const sshAgent = getInput('sshAgent') || '';
|
||||
@@ -57,6 +58,7 @@ const Input = {
|
||||
projectPath,
|
||||
customParameters,
|
||||
testMode,
|
||||
coverageOptions,
|
||||
artifactsPath,
|
||||
useHostNetwork,
|
||||
sshAgent,
|
||||
|
||||
@@ -6,4 +6,19 @@ describe('Output', () => {
|
||||
await expect(Output.setArtifactsPath('')).resolves.not.toThrow();
|
||||
});
|
||||
});
|
||||
describe('setCoveragePath', () => {
|
||||
it('does not throw', async () => {
|
||||
await expect(Output.setCoveragePath('')).resolves.not.toThrow();
|
||||
await expect(Output.setCoveragePath('artifacts')).resolves.not.toThrow();
|
||||
await expect(Output.setCoveragePath('coverage')).resolves.not.toThrow();
|
||||
await expect(Output.setCoveragePath('CodeCoverage')).resolves.not.toThrow();
|
||||
await expect(Output.setCoveragePath('./artifacts')).resolves.not.toThrow();
|
||||
await expect(Output.setCoveragePath('./coverage')).resolves.not.toThrow();
|
||||
await expect(Output.setCoveragePath('./CodeCoverage')).resolves.not.toThrow();
|
||||
await expect(Output.setCoveragePath('./artifacts/coverage')).resolves.not.toThrow();
|
||||
await expect(Output.setCoveragePath('./coverage/')).resolves.not.toThrow();
|
||||
await expect(Output.setCoveragePath('./CodeCoverage/')).resolves.not.toThrow();
|
||||
await expect(Output.setCoveragePath('./artifacts/coverage/')).resolves.not.toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,6 +4,9 @@ const Output = {
|
||||
async setArtifactsPath(artifactsPath) {
|
||||
await core.setOutput('artifactsPath', artifactsPath);
|
||||
},
|
||||
async setCoveragePath(coveragePath) {
|
||||
await core.setOutput('coveragePath', coveragePath);
|
||||
},
|
||||
};
|
||||
|
||||
export default Output;
|
||||
|
||||
Reference in New Issue
Block a user