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

feat: Allow --standard-libraries #14

Merged
merged 6 commits into from
Dec 19, 2024
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
4 changes: 3 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
- name: Set up Dafny
uses: dafny-lang/[email protected]
with:
dafny-version: "4.9.0"
# Using a nightly for now because --standard-libraries
# doesn't work without an unreleased fix
dafny-version: "nightly-2024-12-19-7df92c2"
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
}

dafny {
dafnyVersion.set("4.9.0")
dafnyVersion.set("4.9.1")

optionsMap.put("unicode-char", true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
}

dafny {
dafnyVersion.set("4.9.0")
dafnyVersion.set("4.9.1")

optionsMap.put("unicode-char", false)
}
2 changes: 1 addition & 1 deletion examples/multi-project/consumer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dafny {
dafnyVersion.set("4.9.0")
dafnyVersion.set("4.9.1")
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-project/producer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

dafny {
dafnyVersion.set("4.9.0")
dafnyVersion.set("4.9.1")

optionsMap.put("function-syntax", 3)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/no-dafny/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ repositories {
}

dafny {
dafnyVersion.set("4.9.0")
dafnyVersion.set("4.9.1")
}
2 changes: 1 addition & 1 deletion examples/simple-verify/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ repositories {
}

dafny {
dafnyVersion.set("4.9.0")
dafnyVersion.set("4.9.1")
}
18 changes: 18 additions & 0 deletions examples/using-standard-libraries/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
id("org.dafny.dafny")
}

repositories {
mavenLocal()
mavenCentral()
}

dafny {
dafnyVersion.set("4.9.1")

optionsMap.put("standard-libraries", true)
}

dependencies {
implementation("org.dafny:DafnyRuntime:4.9.0")
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

import opened Std.Wrappers
import opened Std.Collections.Seq

method Main() {
print IndexOfOption([1, 1, 2, 3, 5, 8, 13, 21], 5);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DafnyPluginFunctionalTest {
}

@Test void canReferenceDependencies() throws IOException {
BuildResult result = GradleRunner.create()
GradleRunner.create()
.forwardOutput()
.withPluginClasspath()
.withArguments("clean", "build")
Expand All @@ -58,7 +58,7 @@ class DafnyPluginFunctionalTest {
}

@Test void succeedsWithNoDafnySourceFiles() throws IOException {
BuildResult result = GradleRunner.create()
GradleRunner.create()
.forwardOutput()
.withPluginClasspath()
.withArguments("clean", "build")
Expand All @@ -76,4 +76,17 @@ class DafnyPluginFunctionalTest {
Assertions.assertTrue(result.getOutput().contains(
"Incorrect Dafny version: expected 2.3.0, found"));
}

// Regression test: this previously failed because the standard libraries
// end up included in the .doo file,
// so passing `--standard-libraries` again when translating led to duplicate definitions.
// Dafny has addressed this by not including the standard libraries which building .doo files.
@Test void supportsStandardLibraries() throws IOException {
GradleRunner.create()
.forwardOutput()
.withPluginClasspath()
.withArguments("clean", "build")
.withProjectDir(new File("examples/using-standard-libraries"))
.build();
}
}
2 changes: 2 additions & 0 deletions src/main/java/org/dafny/gradle/plugin/DafnyTranslateTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public abstract class DafnyTranslateTask extends DafnyBaseTask {

Expand Down
Loading