Skip to content

Commit 4dfb089

Browse files
committed
Add support for Eio library in dependency analysis; enhance caching mechanism with skip options and improve benchmark testing. Update README with new test instructions and add benchmark executable.
1 parent 3b8524c commit 4dfb089

File tree

12 files changed

+327
-131
lines changed

12 files changed

+327
-131
lines changed

README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,46 @@ You can run tests using the following methods:
5050
# Run all tests
5151
dune runtest
5252

53-
# Run tests in a specific directory
54-
dune runtest test/
53+
# Run specific tests:
54+
dune exec test/test_cmt_values.exe # Directly execute the test
55+
dune exec test/test_cmt_imports.exe # Directly execute the test
5556

56-
# Run specific tests
57-
dune runtest test/test_cmt_imports.exe
58-
dune runtest test/test_cmt_values.exe
59-
60-
# Run tests directly
61-
dune exec test/test_cmt_imports.exe
57+
# Run benchmark
58+
dune build @bench # Build and run the benchmark
59+
dune exec test/benchmark.exe # Directly execute the benchmark
6260
```
6361

6462
Test code is located in the `test/` directory and includes the following tests:
6563

6664
- `test_cmt_imports.ml`: Tests the import information from cmt files.
6765
- `test_cmt_values.ml`: Tests the value dependency information from cmt files.
66+
- `test_rescriptdep.ml`: Basic smoke test for the rescriptdep functionality.
67+
- `benchmark.ml`: Performance benchmark for the parser.
68+
69+
#### Running the Benchmark
70+
71+
The benchmark is designed to be run separately from the regular tests and requires a ReScript project with compiled .cmt files to analyze:
72+
73+
```bash
74+
# Run the benchmark with a specific ReScript project
75+
RESCRIPTDEP_BENCHMARK_PATH=/path/to/rescript/project/lib/bs/src dune exec test/benchmark.exe
76+
77+
# Example with environment variables for detailed output
78+
RESCRIPTDEP_BENCHMARK=1 RESCRIPTDEP_VERBOSE=1 RESCRIPTDEP_BENCHMARK_PATH=/path/to/project/lib/bs/src dune exec test/benchmark.exe
79+
```
80+
81+
When running as part of `dune runtest`, the benchmark will be skipped automatically.
82+
83+
#### Test Fixtures
84+
85+
Fixture files used by tests are located in the `test/fixtures/` directory. These files include:
86+
87+
- `app.cmt`: Example application module.
88+
- `math.cmt`: Example math utility module.
89+
- `logger.cmt`: Example logging module.
90+
- `utils.cmt`: Example utilities module.
6891

69-
When modifying test code, check the configuration in the `test/dune` file. Fixture files used by tests are located in the `test/fixtures/` directory.
92+
Tests automatically locate these fixture files, so they should work correctly regardless of your current working directory.
7093

7194
## License
7295

bin/main.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ let main () =
100100
if !skip_cache then (
101101
if !verbose then Printf.eprintf "Skipping cache usage\n";
102102
Rescriptdep.Parser.clear_cache ();
103-
Rescriptdep.Parser.parse_files_or_dirs ~verbose:!verbose !input_files)
104-
else Rescriptdep.Parser.parse_files_or_dirs ~verbose:!verbose !input_files
103+
Rescriptdep.Parser.parse_files_or_dirs ~verbose:!verbose
104+
~skip_cache:true !input_files)
105+
else
106+
Rescriptdep.Parser.parse_files_or_dirs ~verbose:!verbose
107+
~skip_cache:false !input_files
105108
in
106109

107110
time_checkpoint "Parsing completed";

dune-project

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
(ocaml
2626
(= 5.3.0))
2727
dune
28+
eio
29+
eio_main
2830
(odoc :with-doc))
2931
(tags
3032
(topics "dependency analysis" "ReScript" "OCaml")))

lib/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
(:standard -w -27-32-33-34-37-39-50-52))
55
(public_name rescriptdep)
66
(modules parse_utils parser formatter dependency_graph)
7-
(libraries str unix vendor))
7+
(libraries str unix vendor eio eio_main))

0 commit comments

Comments
 (0)