From 26f58c8bdb7140f0602dccbbd48017df7ebb8f9f Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Thu, 8 Oct 2020 13:42:11 +0200 Subject: [PATCH] Fix build tools git tests on windows 7x (#63456) * Add error logging for git commands in build-tools integTests * Explicitly set user and email in git related func tests --- .../fixtures/AbstractGradleFuncTest.groovy | 17 ++++++++++++++--- ...nalDistributionBwcSetupPluginFuncTest.groovy | 10 ++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractGradleFuncTest.groovy b/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractGradleFuncTest.groovy index 90734ac4fef..69658330127 100644 --- a/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractGradleFuncTest.groovy +++ b/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractGradleFuncTest.groovy @@ -112,8 +112,19 @@ abstract class AbstractGradleFuncTest extends Specification { } void setupLocalGitRepo() { - "git init".execute(Collections.emptyList(), testProjectDir.root).waitFor() - "git add .".execute(Collections.emptyList(), testProjectDir.root).waitFor() - 'git commit -m "Initial"'.execute(Collections.emptyList(), testProjectDir.root).waitFor() + execute("git init") + execute('git config user.email "build-tool@elastic.co"') + execute('git config user.name "Build tool"') + execute("git add .") + execute('git commit -m "Initial"') + } + + void execute(String command, File workingDir = testProjectDir.root) { + def proc = command.execute(Collections.emptyList(), workingDir) + proc.waitFor() + if(proc.exitValue()) { + println "Error running command ${command}:" + println "Syserr: " + proc.errorStream.text + } } } diff --git a/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPluginFuncTest.groovy index 295d3a38f32..3b4132eaec5 100644 --- a/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPluginFuncTest.groovy +++ b/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPluginFuncTest.groovy @@ -142,10 +142,12 @@ class InternalDistributionBwcSetupPluginFuncTest extends AbstractGradleFuncTest FileUtils.copyDirectory(new File(fakeRemote.file), workingRemoteGit) fakeRemote.file + "/.git" gradleRunner(workingRemoteGit, "wrapper").build() - "git init".execute(Collections.emptyList(), workingRemoteGit).waitFor() - "git add .".execute(Collections.emptyList(), workingRemoteGit).waitFor() - 'git commit -m"Initial"'.execute(Collections.emptyList(), workingRemoteGit).waitFor() - "git checkout -b origin/8.0".execute(Collections.emptyList(), workingRemoteGit).waitFor() + execute("git init", workingRemoteGit) + execute('git config user.email "build-tool@elastic.co"', workingRemoteGit) + execute('git config user.name "Build tool"', workingRemoteGit) + execute("git add .", workingRemoteGit) + execute('git commit -m"Initial"', workingRemoteGit) + execute("git checkout -b origin/8.0", workingRemoteGit) return workingRemoteGit; } }