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

Make sure executable ends with .exe under Windows #199

Merged
merged 4 commits into from Feb 4, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/gradle-windows.yml.disabled
@@ -0,0 +1,34 @@
name: Windows Minimal Tests for Gradle

on:
push:
paths:
- 'native-gradle-plugin/**'
- 'samples/**'
- 'common/**'
pull_request:
paths:
- 'native-gradle-plugin/**'
- 'samples/**'
- 'common/**'
workflow_dispatch:

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: graalvm/setup-graalvm@v1
with:
version: 'dev'
java-version: '11'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check and test the Gradle plugin
run: ./gradlew.bat :native-gradle-plugin:functionalTest --no-daemon --fail-fast
- name: Tests results
if: always()
uses: actions/upload-artifact@v2
with:
name: windows-gradle-functional-tests-results
path: native-gradle-plugin/build/reports/tests/
34 changes: 34 additions & 0 deletions .github/workflows/maven-windows.yml.disabled
@@ -0,0 +1,34 @@
name: Windows Minimal Tests for Maven

on:
push:
paths:
- 'native-maven-plugin/**'
- 'samples/**'
- 'common/**'
pull_request:
paths:
- 'native-maven-plugin/**'
- 'samples/**'
- 'common/**'
workflow_dispatch:

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: graalvm/setup-graalvm@v1
with:
version: 'dev'
java-version: '11'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check and test the Maven plugin
run: ./gradlew.bat :native-maven-plugin:functionalTest --no-daemon --fail-fast
- name: Tests results
if: always()
uses: actions/upload-artifact@v2
with:
name: windows-maven-functional-tests-results
path: native-maven-plugin/build/reports/tests/
4 changes: 4 additions & 0 deletions docs/src/docs/asciidoc/index.adoc
Expand Up @@ -22,6 +22,10 @@ If you are interested in contributing, please refer to our https://github.com/gr
* Native testing support can now be explicitly disabled via `skipNativeTests`.
- See <<maven-plugin.adoc#testing-support-disabling, Disabling testing support>> for details.

==== Gradle plugin

* Fixed `nativeRun` not working properly under Windows

=== Release 0.9.9

==== Gradle plugin
Expand Down
Expand Up @@ -73,6 +73,7 @@
import java.nio.file.Paths;
import java.util.List;

import static org.graalvm.buildtools.utils.SharedConstants.EXECUTABLE_EXTENSION;
import static org.graalvm.buildtools.utils.SharedConstants.GU_EXE;
import static org.graalvm.buildtools.utils.SharedConstants.NATIVE_IMAGE_EXE;

Expand Down Expand Up @@ -106,10 +107,15 @@ protected Provider<String> getGraalVMHome() {
}

@Internal
public Provider<String> getExecutableName() {
public Provider<String> getExecutableShortName() {
return getOptions().flatMap(NativeImageOptions::getImageName);
}

@Internal
public Provider<String> getExecutableName() {
return getOptions().flatMap(options -> options.getImageName().map(name -> name + EXECUTABLE_EXTENSION));
}

@Internal
public Provider<RegularFile> getOutputFile() {
return getOutputDirectory().map(dir -> dir.file(getExecutableName()).get());
Expand Down Expand Up @@ -150,7 +156,7 @@ private List<String> buildActualCommandLineArgs() {
return new NativeImageCommandLineProvider(
getOptions(),
getAgentEnabled(),
getExecutableName(),
getExecutableShortName(),
// Can't use getOutputDirectory().map(...) because Gradle would complain that we use
// a mapped value before the task was called, when we are actually calling it...
getProviders().provider(() -> getOutputDirectory().getAsFile().get().getAbsolutePath()),
Expand Down
Expand Up @@ -129,15 +129,15 @@ abstract class AbstractFunctionalTest extends Specification {
}

void outputContains(String text) {
assert output.contains(text)
assert output.contains(normalizeString(text))
}

void outputDoesNotContain(String text) {
assert !output.contains(text)
assert !output.contains(normalizeString(text))
}

void errorOutputContains(String text) {
assert errorOutput.contains(text)
assert errorOutput.contains(normalizeString(text))
}

void tasks(@DelegatesTo(value = TaskExecutionGraph, strategy = Closure.DELEGATE_FIRST) Closure spec) {
Expand All @@ -148,8 +148,8 @@ abstract class AbstractFunctionalTest extends Specification {
}

private void recordOutputs() {
output = outputWriter.toString()
errorOutput = errorOutputWriter.toString()
output = normalizeString(outputWriter.toString())
errorOutput = normalizeString(errorOutputWriter.toString())
}

private GradleRunner newRunner(String... args) {
Expand Down Expand Up @@ -243,4 +243,8 @@ abstract class AbstractFunctionalTest extends Specification {
}
}
}

private static String normalizeString(String input) {
input.replace("\r\n", "\n")
}
}
Expand Up @@ -131,14 +131,18 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
}

boolean outputContains(String text) {
result.stdOut.contains(text)
normalizeString(result.stdOut).contains(normalizeString(text))
}

boolean outputDoesNotContain(String text) {
!result.stdOut.contains(text)
!normalizeString(result.stdOut).contains(normalizeString(text))
}

File file(String path) {
testDirectory.resolve(path).toFile()
}

private static String normalizeString(String input) {
input.replace("\r\n", "\n")
}
}