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

Keep test folders of failed build tools integration tests #89296

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.apache.commons.io.FileUtils
import org.elasticsearch.gradle.internal.test.ConfigurationCacheCompatibleAwareGradleRunner
import org.elasticsearch.gradle.internal.test.InternalAwareGradleRunner
import org.elasticsearch.gradle.internal.test.NormalizeOutputGradleRunner
import org.elasticsearch.gradle.internal.test.TestResultExtension
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.junit.Rule
Expand Down Expand Up @@ -47,9 +48,9 @@ abstract class AbstractGradleFuncTest extends Specification {
}

def cleanup() {
// if (Boolean.getBoolean('test.keep.samplebuild')) {
if (featureFailed()) {
FileUtils.copyDirectory(testProjectDir.root, new File("build/test-debug/" + testProjectDir.root.name))
// }
}
}

File subProject(String subProjectPath) {
Expand Down Expand Up @@ -205,6 +206,13 @@ checkstyle = "com.puppycrawl.tools:checkstyle:10.3"

}

boolean featureFailed() {
specificationContext.currentSpec.listeners
.findAll { it instanceof TestResultExtension.ErrorListener }
.any {
(it as TestResultExtension.ErrorListener).errorInfo != null }
}

static class ProjectConfigurer {
private File projectDir

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

package org.elasticsearch.gradle.internal.test;

import org.spockframework.runtime.AbstractRunListener;
import org.spockframework.runtime.extension.IGlobalExtension;
import org.spockframework.runtime.model.ErrorInfo;
import org.spockframework.runtime.model.IterationInfo;
import org.spockframework.runtime.model.SpecInfo;

public class TestResultExtension implements IGlobalExtension {

@Override
public void visitSpec(SpecInfo spec) {
spec.addListener(new ErrorListener());
}

public static class ErrorListener extends AbstractRunListener {
ErrorInfo errorInfo;

@Override
public void beforeIteration(IterationInfo iteration) {
errorInfo = null;
}

@Override
public void error(ErrorInfo error) {
errorInfo = error;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0 and the Server Side Public License, v 1; you may not use this file except
# in compliance with, at your election, the Elastic License 2.0 or the Server
# Side Public License, v 1.
#

org.elasticsearch.gradle.internal.test.TestResultExtension