feat(gradle): change test glob to include Tests and Test (#26913)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
fa83b36131
commit
ccb0d7d244
@ -202,192 +202,233 @@ describe('@nx/gradle/plugin', () => {
|
||||
`);
|
||||
});
|
||||
|
||||
it('should create nodes with atomized tests targets based on gradle for nested project root', async () => {
|
||||
gradleReport = {
|
||||
gradleFileToGradleProjectMap: new Map<string, string>([
|
||||
['nested/nested/proj/build.gradle', 'proj'],
|
||||
]),
|
||||
buildFileToDepsMap: new Map<string, string>(),
|
||||
gradleFileToOutputDirsMap: new Map<string, Map<string, string>>([
|
||||
['nested/nested/proj/build.gradle', new Map([['build', 'build']])],
|
||||
]),
|
||||
gradleProjectToTasksTypeMap: new Map<string, Map<string, string>>([
|
||||
['proj', new Map([['test', 'Test']])],
|
||||
]),
|
||||
gradleProjectToProjectName: new Map<string, string>([['proj', 'proj']]),
|
||||
};
|
||||
await tempFs.createFiles({
|
||||
'nested/nested/proj/build.gradle': ``,
|
||||
});
|
||||
await tempFs.createFiles({
|
||||
'proj/src/test/java/test/rootTest.java': ``,
|
||||
});
|
||||
await tempFs.createFiles({
|
||||
'nested/nested/proj/src/test/java/test/test.java': ``,
|
||||
});
|
||||
await tempFs.createFiles({
|
||||
'nested/nested/proj/src/test/java/test/test1.java': ``,
|
||||
describe('with atomized tests targets', () => {
|
||||
beforeEach(async () => {
|
||||
gradleReport = {
|
||||
gradleFileToGradleProjectMap: new Map<string, string>([
|
||||
['nested/nested/proj/build.gradle', 'proj'],
|
||||
]),
|
||||
buildFileToDepsMap: new Map<string, string>(),
|
||||
gradleFileToOutputDirsMap: new Map<string, Map<string, string>>([
|
||||
['nested/nested/proj/build.gradle', new Map([['build', 'build']])],
|
||||
]),
|
||||
gradleProjectToTasksTypeMap: new Map<string, Map<string, string>>([
|
||||
['proj', new Map([['test', 'Test']])],
|
||||
]),
|
||||
gradleProjectToProjectName: new Map<string, string>([['proj', 'proj']]),
|
||||
};
|
||||
await tempFs.createFiles({
|
||||
'nested/nested/proj/build.gradle': ``,
|
||||
});
|
||||
await tempFs.createFiles({
|
||||
'proj/src/test/java/test/rootTest.java': ``,
|
||||
});
|
||||
await tempFs.createFiles({
|
||||
'nested/nested/proj/src/test/java/test/aTest.java': ``,
|
||||
});
|
||||
await tempFs.createFiles({
|
||||
'nested/nested/proj/src/test/java/test/bTest.java': ``,
|
||||
});
|
||||
await tempFs.createFiles({
|
||||
'nested/nested/proj/src/test/java/test/cTests.java': ``,
|
||||
});
|
||||
});
|
||||
|
||||
const results = await createNodesFunction(
|
||||
[
|
||||
'nested/nested/proj/build.gradle',
|
||||
'proj/src/test/java/test/rootTest.java',
|
||||
'nested/nested/proj/src/test/java/test/test.java',
|
||||
'nested/nested/proj/src/test/java/test/test1.java',
|
||||
],
|
||||
{
|
||||
buildTargetName: 'build',
|
||||
ciTargetName: 'test-ci',
|
||||
},
|
||||
context
|
||||
);
|
||||
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
[
|
||||
it('should create nodes with atomized tests targets based on gradle for nested project root', async () => {
|
||||
const results = await createNodesFunction(
|
||||
[
|
||||
"nested/nested/proj/build.gradle",
|
||||
{
|
||||
"projects": {
|
||||
"nested/nested/proj": {
|
||||
"metadata": {
|
||||
"targetGroups": {
|
||||
"Test": [
|
||||
"test-ci--test",
|
||||
"test-ci--test1",
|
||||
"test-ci",
|
||||
"test",
|
||||
],
|
||||
},
|
||||
"technologies": [
|
||||
"gradle",
|
||||
],
|
||||
},
|
||||
"name": "proj",
|
||||
"targets": {
|
||||
"test": {
|
||||
"cache": false,
|
||||
"command": "./gradlew proj:test",
|
||||
"dependsOn": [
|
||||
"classes",
|
||||
],
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
],
|
||||
"metadata": {
|
||||
"help": {
|
||||
"command": "./gradlew help --task proj:test",
|
||||
"example": {
|
||||
"options": {
|
||||
"args": [
|
||||
"--rerun",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
"technologies": [
|
||||
"gradle",
|
||||
'nested/nested/proj/build.gradle',
|
||||
'proj/src/test/java/test/rootTest.java',
|
||||
'nested/nested/proj/src/test/java/test/aTest.java',
|
||||
'nested/nested/proj/src/test/java/test/bTest.java',
|
||||
'nested/nested/proj/src/test/java/test/cTests.java',
|
||||
],
|
||||
{
|
||||
buildTargetName: 'build',
|
||||
ciTargetName: 'test-ci',
|
||||
},
|
||||
context
|
||||
);
|
||||
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
[
|
||||
[
|
||||
"nested/nested/proj/build.gradle",
|
||||
{
|
||||
"projects": {
|
||||
"nested/nested/proj": {
|
||||
"metadata": {
|
||||
"targetGroups": {
|
||||
"Test": [
|
||||
"test-ci--aTest",
|
||||
"test-ci--bTest",
|
||||
"test-ci--cTests",
|
||||
"test-ci",
|
||||
"test",
|
||||
],
|
||||
},
|
||||
"technologies": [
|
||||
"gradle",
|
||||
],
|
||||
},
|
||||
"test-ci": {
|
||||
"cache": true,
|
||||
"dependsOn": [
|
||||
{
|
||||
"params": "forward",
|
||||
"projects": "self",
|
||||
"target": "test-ci--test",
|
||||
},
|
||||
{
|
||||
"params": "forward",
|
||||
"projects": "self",
|
||||
"target": "test-ci--test1",
|
||||
},
|
||||
],
|
||||
"executor": "nx:noop",
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Runs Gradle Tests in CI",
|
||||
"help": {
|
||||
"command": "./gradlew help --task proj:test",
|
||||
"example": {
|
||||
"options": {
|
||||
"args": [
|
||||
"--rerun",
|
||||
],
|
||||
"name": "proj",
|
||||
"targets": {
|
||||
"test": {
|
||||
"cache": false,
|
||||
"command": "./gradlew proj:test",
|
||||
"dependsOn": [
|
||||
"classes",
|
||||
],
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
],
|
||||
"metadata": {
|
||||
"help": {
|
||||
"command": "./gradlew help --task proj:test",
|
||||
"example": {
|
||||
"options": {
|
||||
"args": [
|
||||
"--rerun",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
"technologies": [
|
||||
"gradle",
|
||||
],
|
||||
},
|
||||
"nonAtomizedTarget": "test",
|
||||
"technologies": [
|
||||
"gradle",
|
||||
],
|
||||
},
|
||||
},
|
||||
"test-ci--test": {
|
||||
"cache": true,
|
||||
"command": "./gradlew proj:test --tests test",
|
||||
"dependsOn": [
|
||||
"classes",
|
||||
],
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Runs Gradle test nested/nested/proj/src/test/java/test/test.java in CI",
|
||||
"help": {
|
||||
"command": "./gradlew help --task proj:test",
|
||||
"example": {
|
||||
"options": {
|
||||
"args": [
|
||||
"--rerun",
|
||||
],
|
||||
"test-ci": {
|
||||
"cache": true,
|
||||
"dependsOn": [
|
||||
{
|
||||
"params": "forward",
|
||||
"projects": "self",
|
||||
"target": "test-ci--aTest",
|
||||
},
|
||||
{
|
||||
"params": "forward",
|
||||
"projects": "self",
|
||||
"target": "test-ci--bTest",
|
||||
},
|
||||
{
|
||||
"params": "forward",
|
||||
"projects": "self",
|
||||
"target": "test-ci--cTests",
|
||||
},
|
||||
],
|
||||
"executor": "nx:noop",
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Runs Gradle Tests in CI",
|
||||
"help": {
|
||||
"command": "./gradlew help --task proj:test",
|
||||
"example": {
|
||||
"options": {
|
||||
"args": [
|
||||
"--rerun",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
"nonAtomizedTarget": "test",
|
||||
"technologies": [
|
||||
"gradle",
|
||||
],
|
||||
},
|
||||
"technologies": [
|
||||
"gradle",
|
||||
],
|
||||
},
|
||||
},
|
||||
"test-ci--test1": {
|
||||
"cache": true,
|
||||
"command": "./gradlew proj:test --tests test1",
|
||||
"dependsOn": [
|
||||
"classes",
|
||||
],
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Runs Gradle test nested/nested/proj/src/test/java/test/test1.java in CI",
|
||||
"help": {
|
||||
"command": "./gradlew help --task proj:test",
|
||||
"example": {
|
||||
"options": {
|
||||
"args": [
|
||||
"--rerun",
|
||||
],
|
||||
"test-ci--aTest": {
|
||||
"cache": true,
|
||||
"command": "./gradlew proj:test --tests aTest",
|
||||
"dependsOn": [
|
||||
"classes",
|
||||
],
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Runs Gradle test nested/nested/proj/src/test/java/test/aTest.java in CI",
|
||||
"help": {
|
||||
"command": "./gradlew help --task proj:test",
|
||||
"example": {
|
||||
"options": {
|
||||
"args": [
|
||||
"--rerun",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
"technologies": [
|
||||
"gradle",
|
||||
],
|
||||
},
|
||||
"technologies": [
|
||||
"gradle",
|
||||
},
|
||||
"test-ci--bTest": {
|
||||
"cache": true,
|
||||
"command": "./gradlew proj:test --tests bTest",
|
||||
"dependsOn": [
|
||||
"classes",
|
||||
],
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Runs Gradle test nested/nested/proj/src/test/java/test/bTest.java in CI",
|
||||
"help": {
|
||||
"command": "./gradlew help --task proj:test",
|
||||
"example": {
|
||||
"options": {
|
||||
"args": [
|
||||
"--rerun",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
"technologies": [
|
||||
"gradle",
|
||||
],
|
||||
},
|
||||
},
|
||||
"test-ci--cTests": {
|
||||
"cache": true,
|
||||
"command": "./gradlew proj:test --tests cTests",
|
||||
"dependsOn": [
|
||||
"classes",
|
||||
],
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Runs Gradle test nested/nested/proj/src/test/java/test/cTests.java in CI",
|
||||
"help": {
|
||||
"command": "./gradlew help --task proj:test",
|
||||
"example": {
|
||||
"options": {
|
||||
"args": [
|
||||
"--rerun",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
"technologies": [
|
||||
"gradle",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
]
|
||||
`);
|
||||
],
|
||||
]
|
||||
`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -33,8 +33,10 @@ let gradleCurrentConfigHash: string;
|
||||
|
||||
export const GRADLE_BUILD_FILES = new Set(['build.gradle', 'build.gradle.kts']);
|
||||
export const GRADLE_TEST_FILES = [
|
||||
'**/src/test/java/**/*.java',
|
||||
'**/src/test/kotlin/**/*.kt',
|
||||
'**/src/test/java/**/*Test.java',
|
||||
'**/src/test/kotlin/**/*Test.kt',
|
||||
'**/src/test/java/**/*Tests.java',
|
||||
'**/src/test/kotlin/**/*Tests.kt',
|
||||
];
|
||||
|
||||
export const gradleConfigGlob = combineGlobPatterns(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user