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

--show-snippets with default true and off in tests #4087

Merged
merged 88 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
73cb290
Enabling show-snippet option
May 23, 2023
4b5830a
Renaming to align with issue number
May 23, 2023
6bb7c25
Renaming files
May 23, 2023
d268ce6
Fixing formatting
May 23, 2023
7f9686b
Fixing up tests
May 23, 2023
5bfbc77
Missed renaming typo
May 23, 2023
e7fbc8b
Merge branch 'master' into cok-3304-show-snippet
davidcok May 23, 2023
9962f1e
Improving code
May 23, 2023
e50dd4e
Merge branch 'master' into cok-3304-show-snippet
davidcok May 23, 2023
be1cd88
Merge edits
May 23, 2023
e607d49
Merge branch 'cok-3304-show-snippet' of https://github.com/davidcok/d…
May 23, 2023
b366096
Merge branch 'master' into cok-3304-show-snippet
davidcok May 24, 2023
db754da
Merge branch 'master' into cok-3304-show-snippet
davidcok May 24, 2023
55e7359
Merge branch 'master' into cok-3304-show-snippet
davidcok May 25, 2023
7a25759
Merge branch 'master' into cok-3304-show-snippet
davidcok May 25, 2023
2fbf6a5
Merge branch 'master' into cok-3304-show-snippet
davidcok May 25, 2023
d356ce1
Merge branch 'master' into cok-3304-show-snippet
davidcok May 26, 2023
5d40fcd
Setting show-snippets default to true and turing it off in tests
May 26, 2023
3182535
Merge branch 'master' into cok-3304-show-snippet-2
May 26, 2023
8e59c70
Fixes to turn off --show-snippets
May 26, 2023
345b4ea
Misc fixes
May 26, 2023
6d0d904
Merge branch 'master' into cok-3304-show-snippet
davidcok May 27, 2023
a7518a8
Merge branch 'master' into cok-3304-show-snippet-2
davidcok May 27, 2023
a077bae
Edits to error messages
May 27, 2023
f5a0e81
Merge branch 'master' into cok-3304-show-snippet
davidcok May 29, 2023
7a06981
Merge resolution
May 29, 2023
062e8b5
Merge branch 'cok-3304-show-snippet' of https://github.com/davidcok/d…
May 29, 2023
a21ff86
Fixed compile problem
May 29, 2023
fe51320
Mertge resolution
May 29, 2023
a76dca0
Fixing option
May 29, 2023
1c97537
Touchup test
May 30, 2023
f7046ae
Checking errorids when checking examples
May 30, 2023
4b89d56
Adjusting options
May 30, 2023
25a94fe
Attempting auto insertion of show-snippets:false
May 30, 2023
54b833b
Typo
May 30, 2023
314108a
Cleanine up check-examples script
May 30, 2023
b1b488c
Checkpoint in editing
May 30, 2023
011be2c
Checkpointing edits
May 30, 2023
5d43f39
More edits
May 30, 2023
2c5b540
Review edit
May 30, 2023
6227471
Merge branch 'master' into cok-3304-show-snippet-2
davidcok May 30, 2023
654cd6f
Merge branch 'master' into cok-check-errorids
davidcok May 30, 2023
79a0c0d
Test about allocation set
May 30, 2023
fc2c4c5
Merge branch 'cok-check-errorids' of https://github.com/davidcok/dafn…
May 30, 2023
17c72d0
Merge resolution
May 30, 2023
98d4493
Merging
May 30, 2023
81bf90e
Test fixes
May 31, 2023
3a70693
Edits to get checks working
May 31, 2023
e486087
Debugging file location
May 31, 2023
61c46eb
Debugging legacy behavior
May 31, 2023
e871503
Merge branch 'master' into cok-check-errorids
davidcok May 31, 2023
588bf19
Merge branch 'master' into cok-check-errorids
davidcok May 31, 2023
f0f147e
Merge branch 'master' into cok-check-errorids
May 31, 2023
fde6a52
Adding to CI tests
May 31, 2023
6f3ad0b
Merge branch 'cok-check-errorids' of https://github.com/davidcok/dafn…
May 31, 2023
b74eb00
Typo
May 31, 2023
38f239b
Merge branch 'master' into cok-check-errorids
davidcok May 31, 2023
5559120
Typos
May 31, 2023
c3df0a6
Merge branch 'cok-check-errorids' of https://github.com/davidcok/dafn…
May 31, 2023
df3a9fd
Merging
May 31, 2023
b68db72
Touchups
May 31, 2023
6f6e321
Merging
May 31, 2023
1b6e054
Merge branch 'master' into cok-3304-show-snippet-2
Jun 1, 2023
8aea9f3
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 1, 2023
1bbf084
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 1, 2023
8f2411f
Merge branch 'master' into cok-3304-show-snippet-2
Jun 8, 2023
3996edd
Removing new style option from old style commands
Jun 8, 2023
31b4afe
Cleaning up tets for show-snippets
Jun 8, 2023
96cfbdc
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 8, 2023
a46f60d
more test tweaks
Jun 8, 2023
cf82161
Merge branch 'cok-3304-show-snippet-2' of https://github.com/davidcok…
Jun 8, 2023
d7a61ab
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 8, 2023
9060f25
Adjusting condition
Jun 8, 2023
1a115e1
Fixing tests
Jun 8, 2023
c01574e
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 8, 2023
9db0fa4
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 8, 2023
dbd9b2e
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 13, 2023
8cb7f85
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 13, 2023
5ccf7a5
Removing confusing use of
Jun 14, 2023
557a9d5
Merge branch 'cok-3304-show-snippet-2' of https://github.com/davidcok…
Jun 14, 2023
afcc6d2
Merge branch 'master' into cok-3304-show-snippet-2
Jun 14, 2023
ddb4ee8
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 14, 2023
37572ee
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 15, 2023
1a175ac
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 15, 2023
683265b
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 17, 2023
6fe7fa4
Adding a release note
Jun 20, 2023
1d44b6c
Merge branch 'cok-3304-show-snippet-2' of https://github.com/davidcok…
Jun 20, 2023
a2b1a3f
Merge branch 'master' into cok-3304-show-snippet-2
davidcok Jun 20, 2023
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
2 changes: 1 addition & 1 deletion Source/DafnyCore/DafnyConsolePrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void WriteSourceCodeSnippet(Boogie.IToken tok, TextWriter tw) {
tw.WriteLine("");
}

public static readonly Option<bool> ShowSnippets = new("--show-snippets",
public static readonly Option<bool> ShowSnippets = new("--show-snippets", () => true,
"Show a source code snippet for each Dafny message.");

static DafnyConsolePrinter() {
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyCore/Generic/Reporting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public override bool Message(MessageSource source, ErrorLevel level, string erro
errorLine += "\n";
}

if (Options.Get(DafnyConsolePrinter.ShowSnippets)) {
if (Options.Get(DafnyConsolePrinter.ShowSnippets) && tok != Token.NoToken) {
TextWriter tw = new StringWriter();
new DafnyConsolePrinter(Options).WriteSourceCodeSnippet(tok.ToRange(), tw);
Options.OutputWriter.Write(tw.ToString());
Expand Down
10 changes: 8 additions & 2 deletions Source/DafnyDriver/DafnyDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ static DafnyDriver() {
"/compileVerbose:0",

// Set a default time limit, to catch cases where verification time runs off the rails
"/timeLimit:300"
"/timeLimit:300",

// test results do not include source code snippets
"/showSnippets:0"
};

public static readonly string[] NewDefaultArgumentsForTesting = new[] {
Expand All @@ -94,7 +97,10 @@ static DafnyDriver() {
"--use-basename-for-filename",

// Set a default time limit, to catch cases where verification time runs off the rails
"--verification-time-limit=300"
"--verification-time-limit=300",

// test results do not include source code snippets
"--show-snippets:false"
};

public static int Main(string[] args) {
Expand Down
10 changes: 5 additions & 5 deletions Source/IntegrationTests/LitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ IEnumerable<string> AddExtraArgs(IEnumerable<string> args, IEnumerable<string> l
return (extraDafnyArguments is null ? args : args.Append(extraDafnyArguments)).Concat(local);
}

string[] defaultResolveArgs = new[] { "resolve", "--use-basename-for-filename" };
string[] defaultVerifyArgs = new[] { "verify", "--use-basename-for-filename", "--cores:2", "--verification-time-limit:300" };
string[] defaultResolveArgs = new[] { "resolve", "--use-basename-for-filename", "--show-snippets:false" };
string[] defaultVerifyArgs = new[] { "verify", "--use-basename-for-filename", "--show-snippets:false", "--cores:2", "--verification-time-limit:300" };
//string[] defaultTranslateArgs = new[] { "translate", "--use-basename-for-filename", "--cores:2", "--verification-time-limit:300" };
string[] defaultBuildArgs = new[] { "build", "--use-basename-for-filename", "--cores:2", "--verification-time-limit:300" };
string[] defaultRunArgs = new[] { "run", "--use-basename-for-filename", "--cores:2", "--verification-time-limit:300" };
string[] defaultBuildArgs = new[] { "build", "--use-basename-for-filename", "--show-snippets:false", "--cores:2", "--verification-time-limit:300" };
string[] defaultRunArgs = new[] { "run", "--use-basename-for-filename", "--show-snippets:false", "--cores:2", "--verification-time-limit:300" };

var substitutions = new Dictionary<string, object> {
{ "%diff", "diff" },
{ "%trargs", "--use-basename-for-filename --cores:2 --verification-time-limit:300" },
{ "%trargs", "--use-basename-for-filename --show-snippets:false --cores:2 --verification-time-limit:300" },
{ "%binaryDir", "." },
{ "%z3", Path.Join("z3", "bin", $"z3-{DafnyOptions.DefaultZ3Version}") },
{ "%repositoryRoot", RepositoryRoot.Replace(@"\", "/") },
Expand Down
3 changes: 2 additions & 1 deletion Test/cli/projectFile/dfyconfig.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ includes = ["src/**/*"]
excludes = ["**/excluded.dfy"]

[options]
warn-shadowing = true
warn-shadowing = true
show-snippets = false
24 changes: 12 additions & 12 deletions Test/cli/projectFile/projectFile.dfy
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
// A project file can specify input files and configure options
// RUN: %baredafny resolve --use-basename-for-filename "%S/dfyconfig.toml" > "%t"
// RUN: %baredafny resolve --show-snippets:false --use-basename-for-filename "%S/dfyconfig.toml" > "%t"

// Test using a URL instead of a local file as a project file
// RUN: ! %baredafny resolve --use-basename-for-filename "https://github.com/dafny-lang/dafny/blob/master/dfyconfig.toml"
// RUN: ! %baredafny resolve --show-snippets:false --use-basename-for-filename "https://github.com/dafny-lang/dafny/blob/master/dfyconfig.toml"

// Test option override behavior
// RUN: %baredafny resolve --use-basename-for-filename "%S/dfyconfig.toml" --warn-shadowing=false >> "%t"
// RUN: %baredafny resolve --show-snippets:false --use-basename-for-filename "%S/dfyconfig.toml" --warn-shadowing=false >> "%t"

// Multiple project files are not allowed
// RUN: ! %baredafny resolve --use-basename-for-filename "%S/dfyconfig.toml" "%S/broken/dfyconfig.toml"
// RUN: ! %baredafny resolve --show-snippets:false --use-basename-for-filename "%S/dfyconfig.toml" "%S/broken/dfyconfig.toml"

// Project files may not contain unknown properties
// RUN: ! %baredafny resolve --use-basename-for-filename "%S/broken/dfyconfig.toml"
// RUN: ! %baredafny resolve --show-snippets:false --use-basename-for-filename "%S/broken/dfyconfig.toml"

// Warn if file contains options that don't exist
// RUN: %baredafny resolve --use-basename-for-filename "%S/broken/invalidOption.toml" >> "%t"
// RUN: %baredafny resolve --show-snippets:false --use-basename-for-filename "%S/broken/invalidOption.toml" >> "%t"

// Project files must be files on disk.
// RUN: ! %baredafny resolve --use-basename-for-filename "%S/doesNotExist/dfyconfig.toml"
// RUN: ! %baredafny resolve --show-snippets:false --use-basename-for-filename "%S/doesNotExist/dfyconfig.toml"

// Project file options must have the right type
// RUN: ! %baredafny resolve --use-basename-for-filename "%S/badTypes/dfyconfig.toml" 2>> "%t"
// RUN: ! %baredafny resolve --show-snippets:false --use-basename-for-filename "%S/badTypes/dfyconfig.toml" 2>> "%t"

// A project file without includes will take all .dfy files as input
// RUN: %baredafny resolve --use-basename-for-filename "%S/noIncludes/dfyconfig.toml" >> "%t"
// RUN: %baredafny resolve --show-snippets:false --use-basename-for-filename "%S/noIncludes/dfyconfig.toml" >> "%t"

// Files included by the project file and on the CLI, duplicate is ignored.
// RUN: %baredafny resolve --use-basename-for-filename "%S/dfyconfig.toml" "%S/src/input.dfy" >> "%t"
// RUN: %baredafny resolve --show-snippets:false --use-basename-for-filename "%S/dfyconfig.toml" "%S/src/input.dfy" >> "%t"

// Files excluded by the project file and included on the CLI, are included
// RUN: ! %baredafny resolve --use-basename-for-filename "%S/dfyconfig.toml" "%S/src/excluded.dfy" >> "%t"
// RUN: ! %baredafny resolve --show-snippets:false --use-basename-for-filename "%S/dfyconfig.toml" "%S/src/excluded.dfy" >> "%t"

// RUN: %diff "%s.expect" "%t"
// RUN: %diff "%s.expect" "%t"
14 changes: 7 additions & 7 deletions Test/cli/zeroCores.dfy
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// RUN: ! %baredafny verify --use-basename-for-filename --cores=0 "%s" 2> "%t"
// RUN: ! %baredafny verify --use-basename-for-filename --cores=earga "%s" 2>> "%t"
// RUN: ! %baredafny verify --use-basename-for-filename --cores=earga% "%s" 2>> "%t"
// RUN: ! %baredafny verify --use-basename-for-filename "%s" >> "%t"
// RUN: ! %baredafny verify --use-basename-for-filename --cores=1 "%s" >> "%t"
// RUN: ! %baredafny verify --use-basename-for-filename --cores=0% "%s" >> "%t"
// RUN: ! %baredafny verify --use-basename-for-filename --cores=50% "%s" >> "%t"
// RUN: ! %baredafny verify --show-snippets:false --use-basename-for-filename --cores=0 "%s" 2> "%t"
// RUN: ! %baredafny verify --show-snippets:false --use-basename-for-filename --cores=earga "%s" 2>> "%t"
// RUN: ! %baredafny verify --show-snippets:false --use-basename-for-filename --cores=earga% "%s" 2>> "%t"
// RUN: ! %baredafny verify --show-snippets:false --use-basename-for-filename "%s" >> "%t"
// RUN: ! %baredafny verify --show-snippets:false --use-basename-for-filename --cores=1 "%s" >> "%t"
// RUN: ! %baredafny verify --show-snippets:false --use-basename-for-filename --cores=0% "%s" >> "%t"
// RUN: ! %baredafny verify --show-snippets:false --use-basename-for-filename --cores=50% "%s" >> "%t"
// RUN: %diff "%s.expect" "%t"

method Foo() ensures false {
Expand Down
4 changes: 2 additions & 2 deletions Test/dafny0/Stdin.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 0 %stdin "module A{}" %baredafny verify --stdin > "%t"
// RUN: %exits-with 4 %stdin "method a() { assert false; }" %baredafny verify --stdin >> "%t"
// RUN: %exits-with 0 %stdin "module A{}" %baredafny verify --show-snippets:false --stdin > "%t"
// RUN: %exits-with 4 %stdin "method a() { assert false; }" %baredafny verify --show-snippets:false --stdin >> "%t"
// RUN: %diff "%s.expect" "%t"

2 changes: 1 addition & 1 deletion Test/dafny4/parse-errors.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: ! %baredafny resolve --use-basename-for-filename "%s" > "%t"
// RUN: ! %baredafny resolve --show-snippets:false --use-basename-for-filename "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

datatype D = B | CCC | E { predicate IsFailure() { E? } function PropagateFailure(): D { E } }
Expand Down
2 changes: 1 addition & 1 deletion Test/dafny4/parse-errors2.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: ! %baredafny resolve --use-basename-for-filename "%s" > "%t"
// RUN: ! %baredafny resolve --use-basename-for-filename --show-snippets:false "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

datatype D = D(z: int, 2: int)
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-1309.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 2 %baredafny verify --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 2 %baredafny verify --show-snippets:false --use-basename-for-filename "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

// Example for Issue 1309 -- not yet fixed
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-1992.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 4 %baredafny verify --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 4 %baredafny verify --use-basename-for-filename --show-snippets:false "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

function foo(x: int): int {
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-2477.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 4 %baredafny verify --use-basename-for-filename --cores:2 --verification-time-limit:300 "%s" > "%t"
// RUN: %exits-with 4 %baredafny verify --show-snippets:false --use-basename-for-filename --cores:2 --verification-time-limit:300 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

trait T {
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-2507.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 2 %baredafny resolve --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 2 %baredafny resolve --use-basename-for-filename --show-snippets:false "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

method Test(i: int) {
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-2959.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 3 %baredafny build --use-basename-for-filename --enforce-determinism "%s" > "%t"
// RUN: %exits-with 3 %baredafny build --show-snippets:false --use-basename-for-filename --enforce-determinism "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

method NondetIf() returns (x: int) {
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-2959a.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 4 %baredafny build --use-basename-for-filename --enforce-determinism "%s" > "%t"
// RUN: %exits-with 4 %baredafny build --show-snippets:false --use-basename-for-filename --enforce-determinism "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

method AlsoNondetIf() returns (x: int) {
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-2959b.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 4 %baredafny build --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 4 %baredafny build --show-snippets:false --use-basename-for-filename "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

method NondetIf() returns (x: int) {
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-3288b.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 2 %baredafny verify --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 2 %baredafny verify --show-snippets:false --use-basename-for-filename "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

module M {
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-3366.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 2 %baredafny verify --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 2 %baredafny verify --show-snippets:false --use-basename-for-filename "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

class C<T> {
Expand Down
4 changes: 2 additions & 2 deletions Test/git-issues/git-issue-3370.dfy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %baredafny build --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 4 %baredafny build --use-basename-for-filename --enforce-determinism "%s" >> "%t"
// RUN: %baredafny build --use-basename-for-filename --show-snippets:false "%s" > "%t"
// RUN: %exits-with 4 %baredafny build --use-basename-for-filename --show-snippets:false --enforce-determinism "%s" >> "%t"
// RUN: %diff "%s.expect" "%t"

method m() {
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-3377.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 2 %baredafny test --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 2 %baredafny test --show-snippets:false --use-basename-for-filename "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

method {:extern} {:test} m(i: int, ghost j: int)
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-3451/git-issue-3451.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 2 %baredafny resolve --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 2 %baredafny resolve --show-snippets:false --use-basename-for-filename "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

// The #line should no longer be special
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-3451/git-issue-3451a.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 2 %baredafny resolve --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 2 %baredafny resolve --use-basename-for-filename --show-snippets:false "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

// The #line should no longer be special
Expand Down
10 changes: 5 additions & 5 deletions Test/git-issues/git-issue-3513/git-issue-3513.dfy
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// RUN: %exits-with 2 %baredafny resolve --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 2 %baredafny resolve --use-basename-for-filename --library:"%S/src/A.dfy" "%s" >> "%t"
// RUN: %baredafny resolve --use-basename-for-filename --library:"%S/src/A.dfy,%S/src/sub/B.dfy" "%s" >> "%t"
// RUN: %baredafny resolve --use-basename-for-filename --library:"%S/src/A.dfy , %S/src/sub/B.dfy" "%s" >> "%t"
// RUN: %baredafny resolve --use-basename-for-filename --library:"%S/src" "%s" >> "%t"
// RUN: %exits-with 2 %baredafny resolve --show-snippets:false --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 2 %baredafny resolve --show-snippets:false --use-basename-for-filename --library:"%S/src/A.dfy" "%s" >> "%t"
// RUN: %baredafny resolve --show-snippets:false --use-basename-for-filename --library:"%S/src/A.dfy,%S/src/sub/B.dfy" "%s" >> "%t"
// RUN: %baredafny resolve --show-snippets:false --use-basename-for-filename --library:"%S/src/A.dfy , %S/src/sub/B.dfy" "%s" >> "%t"
// RUN: %baredafny resolve --show-snippets:false --use-basename-for-filename --library:"%S/src" "%s" >> "%t"
// RUN: %diff "%s.expect" "%t"

module M {
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-3757.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 2 %baredafny resolve --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 2 %baredafny resolve --show-snippets:false --use-basename-for-filename "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

const
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-3757a.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 2 %baredafny resolve --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 2 %baredafny resolve --show-snippets:false --use-basename-for-filename "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

const +
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-3839/git-issue-3839a.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: ! %baredafny test --use-basename-for-filename "%s" > "%t"
// RUN: ! %baredafny test --use-basename-for-filename --show-snippets:false "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

method {:test} M(x: int) returns (r: int)
Expand Down
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-3855.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 4 %baredafny verify --warn-deprecation:false --use-basename-for-filename "%s" > "%t"
// RUN: %exits-with 4 %baredafny verify --show-snippets:false --warn-deprecation:false --use-basename-for-filename "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// Nearly verbatim copy of the text case given in the issue
//SIMULADA
Expand Down
3 changes: 2 additions & 1 deletion Test/lit.site.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ config.suffixes.append('.transcript')
dafnyArgs = [
# We do not want absolute or relative paths in error messages, just the basename of the file
'useBaseNameForFileName',
'showSnippets:0',

# Try to verify 2 verification conditions at once
'vcsCores:2',
Expand Down Expand Up @@ -155,7 +156,7 @@ def buildCmd(cmd, args):
dafny = addParams(buildCmd(dafnyExecutable, dafnyArgs))
boogie = buildCmd(boogieExecutable, boogieArgs)

standardArguments = addParams(' '.join(["--use-basename-for-filename"]))
standardArguments = addParams(' '.join(["--use-basename-for-filename", "--show-snippets"]))

# Inform user what executable is being used
lit_config.note(f'Using Dafny (%dafny): {dafny}\n')
Expand Down
2 changes: 1 addition & 1 deletion Test/logger/TextLogger.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 4 %baredafny verify --log-format:text --isolate-assertions "%s" > "%t"
// RUN: %exits-with 4 %baredafny verify --show-snippets:false --log-format:text --isolate-assertions "%s" > "%t"
// RUN: %OutputCheck --file-to-check "%t" "%s"
// CHECK: Overall outcome: Errors
// CHECK: Overall time: .*
Expand Down
2 changes: 1 addition & 1 deletion Test/logger/TextLoggerBatch.dfy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %exits-with 4 %baredafny verify --log-format:text "%s" > "%t"
// RUN: %exits-with 4 %baredafny verify --show-snippets:false --log-format:text "%s" > "%t"
// RUN: %OutputCheck --file-to-check "%t" "%s"
// CHECK: Overall outcome: Errors
// CHECK: Overall time: .*
Expand Down
2 changes: 1 addition & 1 deletion docs/HowToFAQ/Errors-CommandLine.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ The `printIncludes` option has these alternatives: None, Immediate, Transitive.

<!-- %no-check TODO: Outputs the help document -->
```bash
dafny resolve --quantifier-syntax:2 null.dfy
dafny resolve --show-snippets:false --quantifier-syntax:2 null.dfy
```

This is a generic error message about command-line arguments,
Expand Down
2 changes: 1 addition & 1 deletion docs/OnlineTutorial/Lemmas.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ for zero in an array. What makes this problem interesting is that the array we a
searching in has two special properties: all elements are non-negative, and each successive
element decreases by at most one from the previous element. In code:

<!-- %check-verify Lemmas.1.expect -->
<!-- %check-verify Lemmas.1.expect %options -->
```dafny
method FindZero(a: array<int>) returns (index: int)
requires forall i :: 0 <= i < a.Length ==> 0 <= a[i]
Expand Down
9 changes: 5 additions & 4 deletions docs/check-examples
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ dafny="$dafnydir/dafny"
outdir="$dir/../Test/docexamples"

coverage=0
permOptions="--show-snippets:false "
defOptions="--function-syntax:4 --use-basename-for-filename --unicode-char:false"
legacyOptions="-functionSyntax:4 -useBaseNameForFileName"
legacyOptions="-functionSyntax:4 -useBaseNameForFileName -showSnippets:0"

while getopts 'c' opt; do
case "$opt" in
Expand Down Expand Up @@ -366,7 +367,7 @@ do
if [ "$coverage" == "1" ] ; then
f=$outdir/$(basename $file)_${n}.dfy
if [ "$command" == "%check-legacy" ]; then
echo "// RUN: %exits-with" $expectedExit "%baredafny" $verb $dOptions ${options[@]} '"%s" > "%t"' > "$f"
echo "// RUN: %exits-with" $expectedExit "%baredafny" "/showSnippets:0" $verb $dOptions ${options[@]} '"%s" > "%t"' > "$f"
echo " " >> $f
cat $text >> $f
elif [ "$command" == "%check-cli" ]; then
Expand All @@ -379,11 +380,11 @@ do
else
if [ "$command" == "%check-legacy" ]; then
isverbose=-compileVerbose:$checkIds
(cd "$dir"; "$dafny" $verb $dOptions $isverbose ${options[@]} $text ) > "$actualOut" 2> "$actualError"
(cd "$dir"; "$dafny" /showSnippets:0 $dOptions $isverbose ${options[@]} $text ) > "$actualOut" 2> "$actualError"
else
isverbose=
if [ "$checkIds" == "1" ]; then isverbose="--verbose" ; fi
( cd "$dir" ; "$dafny" $verb $isverbose $dOptions ${options[@]} $text ) > "$actualOut" 2> "$actualError"
( cd "$dir" ; "$dafny" $verb $isverbose $permOptions $dOptions ${options[@]} $text ) > "$actualOut" 2> "$actualError"
fi
actualExit=$?
if [ "$useHeadings" == "1" ]; then
Expand Down
1 change: 1 addition & 0 deletions docs/dev/news/4087.feat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
errors issued in command-line mode now show source code context by default; this behavior can be disabled using the option --show-snippets:false.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would phrase this as "Errors emitted by the command-line interface". "Mode" seems like a strange concept here, since the IDE and CLI are so different as an experience, I wouldn't describe them as two different modes.