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

chore: xUnit-based lit test runner #680

Merged
merged 214 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from 193 commits
Commits
Show all changes
214 commits
Select commit Hold shift + click to select a range
80052b6
Checkpoint
robin-aws May 31, 2020
bfade77
Working version with relative paths
robin-aws Jun 1, 2020
3902ade
Add expected arguments
robin-aws Jun 1, 2020
9eeea1f
XUnit workaround for parallel theories
robin-aws Jun 3, 2020
8eea713
Swtich to NetCore, refactor most of comp/
robin-aws Jun 4, 2020
396db40
Support skipping tests as well, more test fixes
robin-aws Jun 4, 2020
42db438
Generalized test cases to use pseudo-shebangs
robin-aws Jun 5, 2020
57f6708
Refactored to remove brackets from test names
robin-aws Jun 5, 2020
358fb6c
Checkpointing partial work on YAML-based config
robin-aws Jun 8, 2020
d852a10
Got some combinatorial cases working
robin-aws Jun 9, 2020
caf685d
Remove incorrect comment
robin-aws Jun 9, 2020
ac8a5c5
POC of coverting the allocated1 directory to the new format
robin-aws Jun 9, 2020
eb29654
Converted BranchConverage.dfy
robin-aws Jun 10, 2020
262dd34
Remove experimental “shebang” lines
robin-aws Jun 10, 2020
7b09ac6
Special cases for comp/Poly.dfy
robin-aws Jun 10, 2020
b6a589a
Added support for <test file>.$lang.files directory
robin-aws Jun 10, 2020
866d2ec
Missing file
robin-aws Jun 10, 2020
59269cd
Relocated some more additional files
robin-aws Jun 12, 2020
bb01970
Missed file
robin-aws Jun 12, 2020
fd27e50
Lingering lit commands
robin-aws Jun 12, 2020
56ae641
Possibly better /out value
robin-aws Jun 17, 2020
a5874e6
Use temporary directory for build output
robin-aws Jun 18, 2020
88ac6e4
All other deterministic known discrepencies
robin-aws Jun 18, 2020
07634c3
Merge branch 'master' of github.com:dafny-lang/dafny into xunit-theor…
robin-aws Jun 18, 2020
810e1b4
Convert new test case
robin-aws Jun 18, 2020
d2f7e3c
Remove binary from earlier experimentation
robin-aws Jun 18, 2020
24dc118
Progress on running from output directory
robin-aws Jun 21, 2020
766ce71
Hack to locate Binaries directory
robin-aws Jun 21, 2020
c9f3625
Test mostly running out of output directory
robin-aws Jun 22, 2020
1f521e4
Just go with NetCore version for initial draft PR
robin-aws Jun 22, 2020
1e313c7
Remove reference not available outside of .NET Core
robin-aws Jun 22, 2020
e3e8cea
Fill out README
robin-aws Jun 22, 2020
e983891
TODO to use David’s trick of verifying separately
robin-aws Jun 22, 2020
656775d
Temporarily remove sharding
robin-aws Jun 22, 2020
a70ff92
Solution file moved
robin-aws Jun 22, 2020
0157e2b
Add TODO about traits
robin-aws Jun 22, 2020
0a7ab31
Correct packages location
robin-aws Jun 23, 2020
6d97886
Try msbuild version
robin-aws Jun 23, 2020
ac824df
One fewer .Parent for msbuild
robin-aws Jun 23, 2020
c462c00
Another TODO
robin-aws Jun 25, 2020
926471c
Fix parallel execution from msbuild, add sharding
robin-aws Jun 26, 2020
daf71e9
Fix sharding
robin-aws Jun 27, 2020
9a5880e
Use DiffPlex for unified diff
robin-aws Jul 3, 2020
e1a39dd
Move solution files back under Source
robin-aws Jul 3, 2020
0fa9b7a
Missing path changes
robin-aws Jul 3, 2020
c6622b3
More code reorganization, start on conversion script
robin-aws Jul 4, 2020
6c60719
More progress on test conversion script
robin-aws Jul 8, 2020
5219755
Be stricter about supported lit test pattern
robin-aws Jul 9, 2020
80c1027
Merge branch 'master' of github.com:dafny-lang/dafny into xunit-theor…
robin-aws Jul 9, 2020
7988dbc
Fix indendation
robin-aws Jul 9, 2020
45b6152
Applied David’s optimization (verify once, compile many)
robin-aws Jul 10, 2020
55b7d76
Fix solution reference in build
robin-aws Jul 10, 2020
b6bdb52
Fix CSharpStyling.dfy.expect
robin-aws Jul 10, 2020
1d9f6de
Improved path handling between frameworks
robin-aws Jul 10, 2020
350ac23
Switch back to single test argument (working now?)
robin-aws Jul 12, 2020
d0bdb27
Merge branch 'master' of github.com:dafny-lang/dafny into xunit-theor…
robin-aws Jul 12, 2020
06530bc
Merge branch 'master' of github.com:dafny-lang/dafny into xunit-theor…
robin-aws Sep 28, 2020
e098b39
Add DafnyTests project back
robin-aws Sep 28, 2020
e132a82
Fix reference to Dafny binary
robin-aws Sep 28, 2020
16b17b9
Better reference to Dafny binary
robin-aws Sep 29, 2020
bcdff33
Lots of fixes to the framework, updating expectations
robin-aws Sep 29, 2020
96477c3
A few more fixes
robin-aws Sep 29, 2020
01653f7
Progress on lit test convertor
robin-aws Sep 30, 2020
e6deb41
Improve lit test conversion approach
robin-aws Oct 1, 2020
56a1e4b
First cut of generic YamlFileDataAttribute
robin-aws Oct 1, 2020
77cc5ba
Add switches to YamlFileDataAttribute
robin-aws Oct 1, 2020
3995823
Extract YamlFileDataDiscoverer (for customization)
robin-aws Oct 2, 2020
0bdfdda
Hook up GetYamlParser (whew)
robin-aws Oct 2, 2020
55096e9
Add ForEachAttribute
robin-aws Oct 3, 2020
b6424aa
Move EnumerableUtils inside XunitExtensions
robin-aws Oct 3, 2020
abcfc8e
Add custom data discoverer test
robin-aws Oct 3, 2020
a6627c9
Use resources instead of files
robin-aws Oct 4, 2020
fe15a29
Progress on actual dafny test cases
robin-aws Oct 5, 2020
fa68a97
Better solution for capturing the resource name
robin-aws Oct 5, 2020
6dd4597
Got an actual Dafny test working again!
robin-aws Oct 5, 2020
b98cc63
More test spec fixes
robin-aws Oct 6, 2020
970379a
Got most of the comp tests working again
robin-aws Oct 7, 2020
0141c50
Fix BranchCoverage.dfy.expect line numbers
robin-aws Oct 7, 2020
55530f4
Hook up expected exit code
robin-aws Oct 8, 2020
f786ec3
Better approach to compile target overrides
robin-aws Oct 9, 2020
6b01bfd
All comp tests passing (with lots marked as known issues)
robin-aws Oct 9, 2020
65aec14
Fix GHA build to use dotnet
robin-aws Oct 9, 2020
2f5e650
Force add missing ignored files
robin-aws Oct 9, 2020
12e1e9c
Reset Hello.dfy execute bits (from experimentation with shebangs)
robin-aws Oct 9, 2020
8e85a2f
Move Library.* files for ExternCtors.dfy back
robin-aws Oct 9, 2020
596196a
Refactor some constants
robin-aws Oct 11, 2020
03658d7
Weird issue around Process.ExitCode being wrong?
robin-aws Oct 13, 2020
a70ebb8
Remove DontRunMe.dfy, refactor covertor code
robin-aws Oct 13, 2020
ce0a8ab
Tweak test configuration to make xunit conversion easier
robin-aws Oct 13, 2020
60f8f8d
Merge branch 'test-cleanup-for-xunit-conversion' of github.com:robin-…
robin-aws Oct 13, 2020
2da02cc
More progress on test conversion script
robin-aws Oct 15, 2020
703e3b0
Partial work on expanding out of comp dir
robin-aws May 16, 2021
8ba6c5d
Merge branch 'master' into xunit-theory-tests
robin-aws May 29, 2021
4402f53
Switch to invoking dotnet instead of dafny executable
robin-aws May 29, 2021
a0a24bd
Fix expectation path, fix arguments
robin-aws May 29, 2021
89b160f
Poke CI
robin-aws May 30, 2021
081f367
fix: Temporarily locking down previous dotnet SDK version
robin-aws May 30, 2021
2d1a00b
Fix target framework on new projects
robin-aws May 30, 2021
0894cd2
Merge branch 'ci-test' into xunit-theory-tests
robin-aws May 30, 2021
5f9ea8e
Merge branch 'master' of https://github.com/dafny-lang/dafny into xun…
robin-aws Aug 5, 2021
b935ecb
Update Source/DafnyTests/DafnyTestCase.cs
robin-aws Aug 6, 2021
7af490a
Update Source/DafnyTests/DafnyTestCase.cs
robin-aws Aug 6, 2021
3d37243
Misc. PR feedback
robin-aws Aug 6, 2021
ec84d25
Rename DafnyTests -> DafnyDriver.Test
robin-aws Aug 6, 2021
153d830
Missing package reference
robin-aws Aug 6, 2021
b119135
Extract some classes into their own files
robin-aws Aug 7, 2021
0056b2d
Merge branch 'master' of https://github.com/dafny-lang/dafny into xun…
robin-aws Aug 7, 2021
147b481
Factor out (mostly) generic CLITestCase
robin-aws Aug 8, 2021
d0f3502
Add LitTestConvertor.Test package
robin-aws Aug 9, 2021
0eaba59
Merge branch 'master' of https://github.com/dafny-lang/dafny into xun…
robin-aws Aug 9, 2021
42c6781
Revert experimental Test refactorings
robin-aws Aug 9, 2021
4afdd35
Nice merge job, dude :)
robin-aws Aug 9, 2021
94ce613
Revert changes to lit job and temporarily disable
robin-aws Aug 9, 2021
62056b9
Starting to add proper meta unit tests
robin-aws Aug 10, 2021
7bb72c2
Partial work dropping the need for EmbeddedResource
robin-aws Aug 11, 2021
ebf71da
Removing EmbeddedResource support, just use files!
robin-aws Aug 11, 2021
2c9d3a7
First cut of an xUnit test that runs lit tests directly
robin-aws Aug 12, 2021
07216c9
More progress on debugging lit tests directly
robin-aws Aug 23, 2021
2416327
More progress on generalizing
robin-aws Aug 26, 2021
7613ba5
More progress - can't find z3 yet
robin-aws Aug 26, 2021
f7033ee
More clean up and removing code out of scope for now
robin-aws Aug 27, 2021
789c900
Add invokeDirectly parameter to test data discoverer
robin-aws Aug 28, 2021
123937a
Fixing C++ test cases
robin-aws Aug 30, 2021
d274ed1
Merge branch 'master' of https://github.com/dafny-lang/dafny into xun…
robin-aws Aug 30, 2021
b7172b5
Autoformat
robin-aws Aug 30, 2021
b968ec1
Dumping more code we don't need yet, fixing warnings
robin-aws Aug 30, 2021
0f7a204
Move XUnitExtensions code to its own package
robin-aws Aug 30, 2021
7f8c23a
Fix assembly reference
robin-aws Aug 30, 2021
ecb61c5
Move shard filtering to a separate collection "orderer" ;)
robin-aws Aug 30, 2021
0e48658
Half-done refactoring to customize test cases more
robin-aws Aug 31, 2021
206ce46
More progress on specialized FileTestCases
robin-aws Sep 9, 2021
70ba1dd
Add skipped rows for unconvertible files
robin-aws Sep 12, 2021
b63cc99
Fix display names
robin-aws Sep 14, 2021
0cc5e48
Checkpointing partial work abstracting to general Lit tests
robin-aws Sep 28, 2021
1c521bd
Better model for IListTestCommands
robin-aws Sep 29, 2021
86d05c4
Various fixes - passes majority of tests now!
robin-aws Sep 30, 2021
0ca1b42
Fix Javascript tests, path issues with file arguments
robin-aws Oct 1, 2021
6bd6250
Rename package
robin-aws Oct 1, 2021
5003bbd
Merge branch 'master' of https://github.com/dafny-lang/dafny into xun…
robin-aws Oct 4, 2021
79d28ac
Fix bad merge conflict resolution
robin-aws Oct 4, 2021
347d1dd
Cleanup
robin-aws Oct 4, 2021
efe3d9b
More clean up, try enabling tests in CI to measure time
robin-aws Oct 4, 2021
737ccde
Move non-compiled runtime files into DafnyRuntime project
robin-aws Oct 4, 2021
8b851c8
Fix packaging and unit test job
robin-aws Oct 7, 2021
fa385be
Merge branch 'master' of https://github.com/dafny-lang/dafny into xun…
robin-aws Oct 7, 2021
e2c5838
Build java runtime before unit tests
robin-aws Oct 9, 2021
c8be4f6
Merge branch 'master' of https://github.com/dafny-lang/dafny into xun…
robin-aws Oct 9, 2021
9ca99a9
Move building Java runtime earlier
robin-aws Oct 9, 2021
6a91afa
Create Output directory explicitly
robin-aws Oct 9, 2021
b273512
Remove unnecessary namespace
robin-aws Oct 10, 2021
64d8b20
Environment variables for pointing to released executables
robin-aws Oct 10, 2021
ddb84b7
Missing solution line
robin-aws Oct 12, 2021
3627445
Improve exception message on non-zero exit code
robin-aws Oct 13, 2021
901dcb4
Removed use of sed from test
robin-aws Oct 13, 2021
a17ea03
Use %refmanexamples to avoid relative paths
robin-aws Oct 13, 2021
255152a
Improved handling of current directory differences
robin-aws Oct 13, 2021
82e3779
Handle quotes in commands, fix a few more tests
robin-aws Oct 14, 2021
316be19
Remove unnecessary sed commands
robin-aws Oct 14, 2021
2e1f03e
Support input redirection, XFAIL (not working yet)
robin-aws Oct 14, 2021
0906cb1
Fix more tests using %S, trying without absolute path magic
robin-aws Oct 15, 2021
deae7f5
timeLimit
robin-aws Oct 15, 2021
3e30b03
Fixed XFAIL handling
robin-aws Oct 15, 2021
b19782f
Added %S as needed
robin-aws Oct 15, 2021
6e3e148
Merge branch 'master' of https://github.com/dafny-lang/dafny into xun…
robin-aws Oct 15, 2021
ca9c15e
Adding || support, fixing legit bug, etc.
robin-aws Oct 15, 2021
b1d24c8
Partial progress on TestGeneration.dfy
robin-aws Oct 15, 2021
642ece0
Clean up pointing at released dafny
robin-aws Oct 15, 2021
cdf6a00
Add 2> support to fix TestAttribute.dfy
robin-aws Oct 15, 2021
33dd949
Formatting
robin-aws Oct 15, 2021
04b7daa
Build Java runtime before build in refman.yml
robin-aws Oct 15, 2021
210aca7
Remove over-zealous %S uses
robin-aws Oct 15, 2021
b41e4d1
Add globbing support, continue working on backticks
robin-aws Oct 16, 2021
cb01db4
Fix broken globbing, remove backtick support, fix last test
robin-aws Oct 17, 2021
d03b1be
Another lexer bug fix
robin-aws Oct 17, 2021
bb88828
Fix XFAIL handling
robin-aws Oct 17, 2021
eaa7364
Add UNSUPPORTED and features
robin-aws Oct 18, 2021
dce7168
Fix ShowSnippets.dfy, debug TestAttribute.dfy
robin-aws Oct 18, 2021
c851425
Way better load balancing of shards (same as lit's)
robin-aws Oct 18, 2021
52c9f89
Debugging TestAttribute.dfy issues on GHA
robin-aws Oct 18, 2021
dd21ef1
Only two hard problems in computer science... :)
robin-aws Oct 18, 2021
6fa230e
Cleanup and debugging
robin-aws Oct 18, 2021
9465485
Fixed TestAttribute.dfy!
robin-aws Oct 18, 2021
c085376
Restore full test suite
robin-aws Oct 18, 2021
ec81556
Merge branch 'master' of https://github.com/dafny-lang/dafny into xun…
robin-aws Oct 18, 2021
008e028
Move Lit-related classes into separate namespace
robin-aws Oct 19, 2021
062871d
Add DiffCommand
robin-aws Oct 19, 2021
c027ae9
Revert DiffCommand, generalize command parsing to support .transcript…
robin-aws Oct 19, 2021
16668f9
Formatting
robin-aws Oct 19, 2021
87852d8
Simplify file data attributes, exclude Inputs
robin-aws Oct 19, 2021
59543ac
Formatting
robin-aws Oct 19, 2021
71ee992
Fix xunit-tests.yml indentation, excludes refman/examples
robin-aws Oct 19, 2021
5766472
Fix z3 unzipped directory name
robin-aws Oct 20, 2021
ec03867
One more try before I give up
robin-aws Oct 20, 2021
9b4e75b
Okay I lied
robin-aws Oct 20, 2021
123b5c9
Fix customBoogie.patch, misc. cleanup
robin-aws Oct 20, 2021
9b58828
Fixing most nullability warnings
robin-aws Oct 20, 2021
3aaed58
Formatting
robin-aws Oct 20, 2021
4f6bd1e
Misc cleanup
robin-aws Oct 20, 2021
1597031
Merge branch 'master' into xunit-theory-tests
robin-aws Oct 20, 2021
e473dd5
Eliminate parsing reflection, partial work on building jar automatically
robin-aws Oct 20, 2021
90d0318
Merge branch 'xunit-theory-tests' of github.com:robin-aws/dafny into …
robin-aws Oct 20, 2021
f6e1a01
Fix automatic build of DafnyRuntime.jar, remove unnecessary CI steps
robin-aws Oct 20, 2021
ebd302b
Missed a call to build the Java runtime
robin-aws Oct 20, 2021
b5da098
Eliminate a few more nullability warnings
robin-aws Oct 21, 2021
9d4aef0
Exclude Output files, more nullability fixes
robin-aws Oct 21, 2021
c99017b
Fix remaining nullability warnings, flip TreatWarningsAsErrors
robin-aws Oct 21, 2021
65827fa
Formatting
robin-aws Oct 21, 2021
25a65a9
Remove treat warnings as errors for now
Oct 21, 2021
3e169cb
Merge branch 'master' into xunit-theory-tests
keyboardDrummer Oct 21, 2021
30cc008
Merge branch 'master' into xunit-theory-tests
keyboardDrummer Oct 21, 2021
167d2c1
chore: xUnit-based lit test runner
robin-aws Oct 21, 2021
36b880c
Merge branch 'master' of https://github.com/dafny-lang/dafny into xun…
robin-aws Oct 21, 2021
0ca7272
Merge branch 'xunit-theory-tests' of github.com:robin-aws/dafny into …
robin-aws Oct 21, 2021
7023212
Poke CI
robin-aws Oct 21, 2021
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
7 changes: 3 additions & 4 deletions .github/workflows/msbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
java-version: 1.8
- name: Upgrade outdated pip
run: python -m pip install --upgrade pip
- name: Install lit
- name: Install lit
run: pip install lit OutputCheck pyyaml
- uses: actions/setup-node@v1
- run: npm install bignumber.js
Expand All @@ -124,7 +124,6 @@ jobs:
- if: runner.os != 'Windows'
run: |
unzip dafny/Package/CI.zip -d unzippedRelease
- name: Run lit tests
- name: Run integration tests
run: |
## lit in this context needs the executables specified
lit --time-tests -v --num-shards=5 --run-shard=${{ matrix.shard }} --param executable=$PWD/unzippedRelease/dafny/dafny --param serverExecutable=$PWD/unzippedRelease/dafny/DafnyServer dafny/Test
XUNIT_SHARD=${{ matrix.shard }} XUNIT_SHARD_COUNT=5 DAFNY_RELEASE=$PWD/unzippedRelease/dafny dotnet test -v:n dafny/Source/IntegrationTests/IntegrationTests.csproj
3 changes: 3 additions & 0 deletions .github/workflows/refman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
with:
submodules: recursive
path: dafny
- name: Build Java runtime
working-directory: dafny
run: make --quiet runtime
- name: Build Dafny
run: dotnet build dafny/Source/Dafny.sln
- name: Install latex pandoc - Linux
Expand Down
28 changes: 13 additions & 15 deletions .github/workflows/xunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jobs:
chmod: true
coverage: false
env:
testPath1: Source/DafnyLanguageServer.Test/bin/Debug/net5.0
testPath2: Source/DafnyPipeline.Test/bin/Debug/net5.0
testPath3: Source/DafnyTestGeneration.Test/bin/Debug/net5.0
solutionPath: Source/Dafny.sln
z3BaseUri: https://github.com/Z3Prover/z3/releases/download/Z3-4.8.5
steps:
Expand All @@ -45,22 +42,23 @@ jobs:
dotnet-version: 5.0.x
- name: Install dependencies
run: dotnet restore ${{env.solutionPath}}
- name: Build
run: dotnet build --no-restore ${{env.solutionPath}}
- name: Build Java runtime
run: make --quiet runtime
- name: Load Z3
shell: pwsh
run: |
Invoke-WebRequest ${{env.z3BaseUri}}/${{matrix.z3}}.zip -OutFile z3.zip
Expand-Archive z3.zip .
Expand-Archive z3.zip ./Binaries/z3
Copy link
Member

Choose a reason for hiding this comment

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

If this is not working, try
Expand-Archive -LiteralPath z3.zip -DestinationPath Binaries/z3

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/expand-archive?view=powershell-7.1

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestion @MikaelMayer! I did eventually get it working in the later commits, but there's probably still a better approach so let me know if I can improve it.

Remove-Item z3.zip
Copy-Item ${{matrix.z3}} ${{env.testPath1}}/z3 -Recurse
Copy-Item ${{matrix.z3}} ${{env.testPath2}}/z3 -Recurse
Copy-Item ${{matrix.z3}} ${{env.testPath3}}/z3 -Recurse
- name: Set Z3 Permissions
if: ${{matrix.chmod}}
run: |
chmod +x ${{env.testPath1}}/z3/bin/z3
chmod +x ${{env.testPath2}}/z3/bin/z3
chmod +x ${{env.testPath3}}/z3/bin/z3
- name: Run Tests
run: dotnet test --no-restore --verbosity normal ${{env.solutionPath}}
run: |
chmod +x Binaries/z3/bin/z3
- name: Build
run: dotnet build --no-restore ${{env.solutionPath}}
- name: Run DafnyLanguageServer Tests
run: dotnet test --no-restore --verbosity normal Source/DafnyLanguageServer.Test
- name: Run DafnyPipeline Tests
run: dotnet test --no-restore --verbosity normal Source/DafnyPipeline.Test
- name: Run DafnyTestGeneration Tests
run: dotnet test --no-restore --verbosity normal Source/DafnyTestGeneration.Test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Package/

Source/*/bin/
Source/*/obj/
Source/*/bin_core/
Source/*/obj_core/
Source/packages

Expand Down
4 changes: 1 addition & 3 deletions Scripts/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
## On unix systems, which Dafny files should be marked as executable? (Glob syntax; Z3's permissions are preserved)
UNIX_EXECUTABLES = ["dafny", "dafny-server"]

ETCs = ["DafnyRuntime.js", "DafnyRuntime.go", "DafnyRuntime.jar", "DafnyRuntime.h"]

# Constants

THIS_FILE = path.realpath(__file__)
Expand Down Expand Up @@ -166,7 +164,7 @@ def pack(self):
lowercaseDafny = path.join(self.buildDirectory, "dafny")
shutil.move(uppercaseDafny, lowercaseDafny)
os.chmod(lowercaseDafny, stat.S_IEXEC| os.lstat(lowercaseDafny).st_mode)
paths = pathsInDirectory(self.buildDirectory) + list(map(lambda etc: path.join(BINARIES_DIRECTORY, etc), ETCs)) + OTHERS
paths = pathsInDirectory(self.buildDirectory) + OTHERS
for fpath in paths:
if os.path.isdir(fpath):
continue
Expand Down
12 changes: 11 additions & 1 deletion Source/Dafny.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DafnyRuntime", "DafnyRuntim
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DafnyPipeline", "Dafny\DafnyPipeline.csproj", "{45FFD363-CFE0-4ABC-984F-7EB58C8BEDE5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DafnyPipeline.Test", "DafnyPipeline.Test\DafnyPipeline.Test.csproj", "{FA2A3A73-3035-497B-B9D7-B6BC4888A058}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DafnyDriver", "DafnyDriver\DafnyDriver.csproj", "{4B74F970-8FEB-46A1-BD14-FBF2B5D5F285}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DafnyServer", "DafnyServer\DafnyServer.csproj", "{71208DB9-31D6-4071-838B-8D44A37CF0F1}"
Expand All @@ -16,11 +18,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
version.cs = version.cs
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests", "IntegrationTests\IntegrationTests.csproj", "{A4BC2C77-3A48-4917-AA22-41978DFFE24E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DafnyLanguageServer", "DafnyLanguageServer\DafnyLanguageServer.csproj", "{CD05D26C-C672-4F43-835E-7A3E1741E4D8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DafnyLanguageServer.Test", "DafnyLanguageServer.Test\DafnyLanguageServer.Test.csproj", "{320C02A3-D3E6-4AC7-A7E2-170AF86A6EEC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DafnyPipeline.Test", "DafnyPipeline.Test\DafnyPipeline.Test.csproj", "{FA2A3A73-3035-497B-B9D7-B6BC4888A058}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitExtensions", "XUnitExtensions\XUnitExtensions.csproj", "{43731A57-DBA9-43AC-BC83-A9211DA7EB77}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DafnyTestGeneration", "DafnyTestGeneration\DafnyTestGeneration.csproj", "{229E0F23-2B99-4331-8BD8-C2EBCB7C9DAC}"
EndProject
Expand Down Expand Up @@ -60,6 +64,10 @@ Global
{FA2A3A73-3035-497B-B9D7-B6BC4888A058}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA2A3A73-3035-497B-B9D7-B6BC4888A058}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA2A3A73-3035-497B-B9D7-B6BC4888A058}.Release|Any CPU.Build.0 = Release|Any CPU
{43731A57-DBA9-43AC-BC83-A9211DA7EB77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43731A57-DBA9-43AC-BC83-A9211DA7EB77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43731A57-DBA9-43AC-BC83-A9211DA7EB77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43731A57-DBA9-43AC-BC83-A9211DA7EB77}.Release|Any CPU.Build.0 = Release|Any CPU
{229E0F23-2B99-4331-8BD8-C2EBCB7C9DAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{229E0F23-2B99-4331-8BD8-C2EBCB7C9DAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{229E0F23-2B99-4331-8BD8-C2EBCB7C9DAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -68,6 +76,8 @@ Global
{896E7F24-FD59-4B34-A1BF-53C51DDBC9E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{896E7F24-FD59-4B34-A1BF-53C51DDBC9E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{896E7F24-FD59-4B34-A1BF-53C51DDBC9E9}.Release|Any CPU.Build.0 = Release|Any CPU
{A4BC2C77-3A48-4917-AA22-41978DFFE24E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4BC2C77-3A48-4917-AA22-41978DFFE24E}.Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
8 changes: 2 additions & 6 deletions Source/Dafny/Compilers/Compiler-cpp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2387,8 +2387,7 @@ public override bool CompileTargetProgram(string dafnyProgramName, string target
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
WorkingDirectory = Path.GetDirectoryName(Path.GetFullPath(targetFilename))
RedirectStandardError = true
};
var proc = Process.Start(psi);
while (!proc.StandardOutput.EndOfStream) {
Expand All @@ -2408,14 +2407,11 @@ public override bool CompileTargetProgram(string dafnyProgramName, string target
public override bool RunTargetProgram(string dafnyProgramName, string targetProgramText, string/*?*/ callToMain, string targetFilename, ReadOnlyCollection<string> otherFileNames,
object compilationResult, TextWriter outputWriter) {
var exeName = ComputeExeName(targetFilename);
var dir = Path.GetDirectoryName(Path.GetFullPath(targetFilename));
var exePath = Path.Combine(dir, exeName);
var psi = new ProcessStartInfo(exePath) {
var psi = new ProcessStartInfo(exeName) {
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
WorkingDirectory = dir
};
var proc = Process.Start(psi);
while (!proc.StandardOutput.EndOfStream) {
Expand Down
5 changes: 4 additions & 1 deletion Source/Dafny/Dafny.atg
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,10 @@ Dafny
{ TopDecl<defaultModule, membersDefaultClass, /* isTopLevel */ true, /* isAbstract */ false> }
(. // find the default class in the default module, then append membersDefaultClass to its member list
if (membersDefaultClass.Count == 0 && defaultModule.Includes.Count == 0 && defaultModule.TopLevelDecls.Count == 0) {
errors.Warning(defaultModule.tok, "File contains no code: " + Path.GetRelativePath(Directory.GetCurrentDirectory(), scanner.FullFilename));
var fileName = DafnyOptions.Clo.UseBaseNameForFileName
? Path.GetFileName(scanner.FullFilename)
: Path.GetRelativePath(Directory.GetCurrentDirectory(), scanner.FullFilename);
errors.Warning(defaultModule.tok, "File contains no code: " + fileName);
}
DefaultClassDecl defaultClass = null;
foreach (TopLevelDecl topleveldecl in defaultModule.TopLevelDecls) {
Expand Down
1 change: 1 addition & 0 deletions Source/Dafny/DafnyOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public static void Install(DafnyOptions options) {
public enum PrintModes { Everything, DllEmbed, NoIncludes, NoGhost };
public PrintModes PrintMode = PrintModes.Everything; // Default to printing everything
public bool DafnyVerify = true;
public bool VerifyVerbose = true;
public string DafnyPrintResolvedFile = null;
public List<string> DafnyPrintExportedViews = new List<string>();
public bool Compile = true;
Expand Down
6 changes: 2 additions & 4 deletions Source/Dafny/DafnyPipeline.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@
<ItemGroup>
<Compile Include="..\version.cs" />
</ItemGroup>

<ItemGroup>
<None Update="DafnyPrelude.bpl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="DafnyPrelude.bpl" CopyToOutputDirectory="PreserveNewest" />
<Content Include="..\..\Binaries\DafnyRuntime.jar" CopyToOutputDirectory="PreserveNewest" />
robin-aws marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
</ItemGroup>

<ItemGroup>
<Content Include="..\..\Binaries\z3\**\*.*" LinkBase="z3">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

<None Update="Lookup\TestFiles\foreign.dfy">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
6 changes: 6 additions & 0 deletions Source/DafnyPipeline.Test/DafnyPipeline.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@
<ProjectReference Include="..\Dafny\DafnyPipeline.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\Binaries\z3\**\*.*" LinkBase="z3">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions Source/DafnyRuntime/DafnyRuntime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<Compile Update="DafnyRuntime.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>
<Content Include="DafnyRuntime.js" CopyToOutputDirectory="PreserveNewest" />
<Content Include="DafnyRuntime.go" CopyToOutputDirectory="PreserveNewest" />
<Content Include="DafnyRuntime.h" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Source/DafnyServer/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Microsoft.Boogie;

namespace Microsoft.Dafny {
class Server {
public class Server {
private bool running;

static void Main(string[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@
<ProjectReference Include="..\DafnyTestGeneration\DafnyTestGeneration.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\Binaries\z3\**\*.*" LinkBase="z3">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
43 changes: 43 additions & 0 deletions Source/IntegrationTests/IntegrationTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DafnyDriver\DafnyDriver.csproj" />
<ProjectReference Include="..\DafnyServer\DafnyServer.csproj" />
<ProjectReference Include="..\XUnitExtensions\XUnitExtensions.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\Binaries\z3\**\*.*" LinkBase="z3">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\Test\**\*.*" LinkBase="TestFiles\LitTests\LitTest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\docs\DafnyRef\examples\**\*.*" LinkBase="TestFiles\LitTests\LitTest\refman\examples">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\node_modules\**\*.*" LinkBase="TestFiles\LitTests\LitTest\node_modules">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
98 changes: 98 additions & 0 deletions Source/IntegrationTests/LitTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.Dafny;
using Xunit;
using Xunit.Abstractions;
using XUnitExtensions;
using XUnitExtensions.Lit;

[assembly: TestCollectionOrderer("XUnitExtensions.TestCollectionShardFilter", "XUnitExtensions")]

namespace IntegrationTests {
public class LitTests {

private static readonly Assembly dafnyDriverAssembly = typeof(DafnyDriver).Assembly;
private static readonly Assembly dafnyServerAssembly = typeof(Server).Assembly;

private static readonly string[] defaultDafnyArguments = new[] {
"/countVerificationErrors:0",

// We do not want absolute or relative paths in error messages, just the basename of the file
"/useBaseNameForFileName",

// We do not want output such as "Compiled program written to Foo.cs"
// from the compilers, since that changes with the target language
"/compileVerbose:0",

// Hide Boogie execution traces since they are meaningless for Dafny programs
"/errorTrace:0",

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

private static ILitCommand MainWithArguments(Assembly assembly, IEnumerable<string> arguments, LitTestConfiguration config, bool invokeDirectly) {
return MainMethodLitCommand.Parse(assembly, arguments, config, invokeDirectly);
}

private static readonly LitTestConfiguration CONFIG = new() {
Commands = new Dictionary<string, Func<IEnumerable<string>, LitTestConfiguration, ILitCommand>> {
{ "%baredafny", (args, config) =>
MainWithArguments(dafnyDriverAssembly, args, config, false) },
{ "%dafny", (args, config) =>
MainWithArguments(dafnyDriverAssembly, defaultDafnyArguments.Concat(args), config, false) },
{ "%server", (args, config) =>
MainWithArguments(dafnyServerAssembly, args, config, false) },
},

Substitions = new Dictionary<string, string> {
{ "%diff", "diff" },
{ "%binaryDir", "." },
{ "%z3", Path.Join("z3", "bin", "z3") },
{ "%refmanexamples", Path.Join("TestFiles", "LitTests", "LitTest", "refman", "examples") }
},

PassthroughEnvironmentVariables = new[] { "PATH", "HOME" },
};

static LitTests() {
var dafnyReleaseDir = Environment.GetEnvironmentVariable("DAFNY_RELEASE");
if (dafnyReleaseDir != null) {
CONFIG.Commands["%baredafny"] = (args, config) =>
new ShellLitCommand(config, Path.Join(dafnyReleaseDir, "dafny"), args, config.PassthroughEnvironmentVariables);
CONFIG.Commands["%dafny"] = (args, config) =>
new ShellLitCommand(config, Path.Join(dafnyReleaseDir, "dafny"), defaultDafnyArguments.Concat(args), config.PassthroughEnvironmentVariables);
CONFIG.Commands["%server"] = (args, config) =>
new ShellLitCommand(config, Path.Join(dafnyReleaseDir, "DafnyServer"), args, config.PassthroughEnvironmentVariables);
CONFIG.Substitions["%z3"] = Path.Join(dafnyReleaseDir, "z3", "bin", "z3");
}

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
CONFIG.Features = new[] { "ubuntu", "posix" };
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
CONFIG.Features = new[] { "windows" };
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
CONFIG.Features = new[] { "macosx", "posix" };
} else {
throw new Exception($"Unsupported OS: {RuntimeInformation.OSDescription}");
}
}

private readonly ITestOutputHelper output;

public LitTests(ITestOutputHelper output) {
this.output = output;
}

[FileTheory]
[FileData(Includes = new[] { "**/*.dfy", "**/*.transcript" },
Excludes = new[] { "**/Inputs/**/*", "refman/examples/**/*" })]
Copy link
Member

Choose a reason for hiding this comment

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

I had a few output files from a previous run that were accidentally picked up as Lit tests, for example this one:

TestFiles/LitTests/LitTest/allocated1/dafny0/Output/Calculations.dfy.tmp.dprint.dfy

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, lit automatically filters out Output files internally. I've addressed this by adding another Exclude here even though the lit test runner should really be responsible for that, since it's a fair bit easier.

Ideally it would be automatic, but another improvement I want to make after this PR is to run each test in a fresh temporary directory instead of a fixed and shared Output directory (I started doing that in earlier versions of this PR in fact but have since trimmed that scope for v1), which will avoid potentially polluting results and also make this issue moot.

public void LitTest(string path) {
LitTestCase.Run(path, CONFIG, output);
}
}
}
Loading