Skip to content

Commit d8f34db

Browse files
committed
Add section on analysis tests
1 parent 8d502ad commit d8f34db

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

analysis/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,28 @@ dune exec -- rescript-editor-analysis --help
2424
## History
2525

2626
This project is based on a fork of [Reason Language Server](https://github.com/jaredly/reason-language-server).
27+
28+
## Tests
29+
30+
The tests in the `analysis/test` folder are based on the `./rescript-editor-analysis.exe test` command. This special subcommand processes a file and executes specific editor analysis functionality based on special syntax found in code comments.
31+
32+
Consider the following code:
33+
34+
```res
35+
let a = 5
36+
// a.
37+
// ^com
38+
```
39+
40+
After building the ReScript project (**⚠️ this is a requirement**), you can execute `./rescript-editor-analysis.exe test Sample.res`, and completion will be executed for the cursor position indicated by `^`. The `com` directive requests completion. To see other commands, check out the pattern match in `test` in [Commands.ml](./src/Commands.ml).
41+
42+
Here’s how it works: once a command is found in a comment, a copy of the source file is created inside a temporary directory, where the line above `^com` is uncommented. The corresponding analysis functionality is then processed, typically with `~debug:true`. With debug enabled, code paths like
43+
44+
```ml
45+
if Debug.verbose () then
46+
print_endline "[complete_typed_value]--> Tfunction #other";
47+
```
48+
49+
will print to stdout. This is helpful for observing what occurs during the analysis.
50+
51+
When you run `make test` (from the `analysis/tests` folder), `./rescript-editor-analysis.exe test <file>` will be executed for each `*.res` file in `analysis/tests/src`. The stdout will be compared to the corresponding `analysis/tests/src/expected` file. If `git diff` indicates changes, `make test` will fail, as these differences might be unintentional.

0 commit comments

Comments
 (0)