Skip to content

Commit

Permalink
Increase default test heap from 512m to 2g (#1813)
Browse files Browse the repository at this point in the history
Increase default test heap from 512m to 2g unless otherwise specified
  • Loading branch information
carterkozak authored Jun 24, 2021
1 parent 487ba99 commit 0e72722
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-1813.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Increase default test heap from 512m to 2g unless otherwise specified
links:
- https://github.com/palantir/gradle-baseline/pull/1813
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void apply(Project project) {
proj.getPluginManager().apply(BaselineExactDependencies.class);
proj.getPluginManager().apply(BaselineReleaseCompatibility.class);
proj.getPluginManager().apply(BaselineTesting.class);
proj.getPluginManager().apply(BaselineTestHeap.class);
proj.getPluginManager().apply(BaselineJavaParameters.class);
proj.getPluginManager().apply(BaselineImmutables.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* (c) Copyright 2019 Palantir Technologies Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.palantir.baseline.plugins;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.tasks.testing.Test;

/**
* Increases the default {@code test} task heap from {@code 512m} to {@code 2g}.
*/
public final class BaselineTestHeap implements Plugin<Project> {

private static final String TEST_HEAP = "2g";

@Override
public void apply(Project project) {
project.getTasks().withType(Test.class).configureEach(testTask -> {
String currentValue = testTask.getMaxHeapSize();
if (currentValue == null) {
testTask.setMaxHeapSize(TEST_HEAP);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
implementation-class=com.palantir.baseline.plugins.BaselineTestHeap
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* (c) Copyright 2018 Palantir Technologies Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.palantir.baseline


import org.gradle.api.tasks.testing.Test
import com.palantir.baseline.plugins.BaselineTestHeap;
import org.gradle.testfixtures.ProjectBuilder
import spock.lang.Specification

class BaselineTestHeapTest extends Specification {

def testDefaultHeapIsIncreased() {
when:
def project = ProjectBuilder.builder().build()
project.buildscript {
repositories {
mavenCentral()
}
}
project.plugins.apply 'java'
project.plugins.apply BaselineTestHeap
project.evaluate()

then:
Test testTask = project.tasks.getByName('test')
testTask.getMaxHeapSize() == '2g'
}

def testOverridesAreNotImpacted() {
when:
def project = ProjectBuilder.builder().build()
project.buildscript {
repositories {
mavenCentral()
}
}
project.plugins.apply 'java'
project.test {
maxHeapSize = '1024m'
}
project.plugins.apply BaselineTestHeap
project.evaluate()

then:
Test testTask = project.tasks.getByName('test')
testTask.getMaxHeapSize() == '1024m'
}
}

0 comments on commit 0e72722

Please sign in to comment.