Skip to content

Commit a373a5c

Browse files
smoothdeveloperbaronfel
authored andcommitted
Add tests/fsharp/readme.md (#6681)
* init a basic readme.md for fsharp test suite * fix title and try to add link * case sensitive? * Update layout. * Update readme.md
1 parent 8e4a2f1 commit a373a5c

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

tests/fsharp/readme.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# F# Compiler Cross-Platform Test Suite
2+
3+
## Layout
4+
5+
The tests are NUNIT test cases.. They test a very wide range of compiler, interactive and FSharp.Core scenarios.
6+
7+
The bulk of the test cases are enumerated in tests.fs, these are the old cambridge test suite. They build on a test-suite ported from windows batch files. They run the compiler and fsi as seperate processes, when built for the coreclr it runs the coreclr versions using dotnet.exe
8+
9+
The framework and utilities can be found in test-framework.fs, single-test.fs, coreclr_utilities.fs.
10+
11+
test cases look similar to:
12+
````
13+
[<Test>]
14+
let ``array-FSI_BASIC`` () = singleTestBuildAndRun "core/array" FSI_BASIC
15+
````
16+
This test case builds and runs the test case in the folder core/array
17+
18+
this #define is used to exclude from the build tests that run will not run correctly on the coreclr
19+
__#if !FSHARP_SUITE_DRIVES_CORECLR_TESTS__
20+
21+
There are some older tests in this section that looks similar to:
22+
````
23+
[<Test>]
24+
let events () =
25+
let cfg = testConfig "core/events"
26+
fsc cfg "%s -a -o:test.dll -g" cfg.fsc_flags ["test.fs"]
27+
peverify cfg "test.dll"
28+
csc cfg """/r:"%s" /reference:test.dll /debug+""" cfg.FSCOREDLLPATH ["testcs.cs"]
29+
peverify cfg "testcs.exe"
30+
use testOkFile = fileguard cfg "test.ok"
31+
fsi cfg "" ["test.fs"]
32+
testOkFile.CheckExists()
33+
exec cfg ("." ++ "testcs.exe") ""
34+
````
35+
These tests build, compile, peverify and run fsi.
36+
37+
Below the Compiler directory there is a set of tests built on the compiler service. They are nunit and instead of executing the compiler and fsi using files on disk the tests are built from memory. These tests use the CompilerAssert framework and look similar to:
38+
39+
This test verifies that a warning is produces when a value is implicitly discarded. The line ````x = 20``` looks like an assignment but in F# is a test for equality it yields and discards the value false.
40+
````
41+
[<Test>]
42+
let ``Unused compare with immutable when assignment might be intended``() =
43+
CompilerAssert.TypeCheckSingleError
44+
"""
45+
let x = 10
46+
let y = "hello"
47+
48+
let changeX() =
49+
x = 20
50+
y = "test"
51+
"""
52+
FSharpErrorSeverity.Warning
53+
20
54+
(6, 5, 6, 11)
55+
"The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then mark the value 'mutable' and use the '<-' operator e.g. 'x <- expression'."
56+
````
57+
58+
59+
## Workflow when adding or fixing tests
60+
61+
When a test is run, .err/.vserr output files are created and compared to their matching .bsl files.
62+
63+
When many tests fail due to a change being worked on, the [update.base.line.with.actuals.fsx](update.base.line.with.actuals.fsx) script helps updating the .bsl against the actuals.
64+
65+
After editing the folder list, evaluating the script should replace the .bsl files with actual .err/.vserr, after which the same test is supposed to pass.
66+
67+
Tests are organized under modules as functions bearing NUnit `[<Test>]` attribute and can be run from an IDE or the command line (see the [Test Guide](../../TESTGUIDE.md)).

0 commit comments

Comments
 (0)