Skip to content

Commit

Permalink
docs: documenting adding a new test to arkscript for new contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperFola committed Jan 7, 2025
1 parent 415511a commit 40f0b6a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Code formatting as well as static analysis is handled through `pre-commit` and i

### Running the test suites

Build the tests using `-DARK_TESTS=On`. It is **strongly recommended** to add `-DARK_COVERAGE=On` to generate coverage reports.
Build the tests using `-DARK_TESTS=On`.

Run the `unittests` target to:
- run various C++ unit tests,
Expand All @@ -43,6 +43,28 @@ Run the `unittests` target to:
- run formatting tests,
- run language tests (`tests/unittests/resources/LangSuite/`)

#### Adding new tests

The easiest tests to add are snapshot tests, in `tests/unittests/resources/...Suite/`. They expect an input `.ark` file and a desired output file (`.expected` or `.json` depending on the suite).

- **ASTSuite** tests the AST parsing, which is then dumped to JSON by the JsonCompiler
- **BytecodeReaderSuite** tests the decoding of ArkScript bytecode files
- **CompilerSuite** tests the IR generation and optimization
- **DiagnosticsSuite** tests the generation of error messages
- **compileTime** for errors generated by the compiler
- **runtime** for errors generated by the virtual machine
- **FormatterSuite** tests the code formatter. Input is badly formatted, output is the expected formatted code
- **LangSuite** are unit tests written in ArkScript itself, testing the builtins and the language
- **NameResolutionSuite** tests the resolution of names and packages with import directives
- **OptimizerSuite** tests the AST optimizer. Nodes should be removed by this pass, we ensure they are not present in the final AST
- **ParserSuite** tests the parser, along with parsing specific errors
- **failure** for the parsing failures
- **success** for the successful parsing, output is the pretty printed AST

#### Coverage reports

It is **recommended** to add `-DARK_COVERAGE=On` to generate coverage reports, this way you can check if your feature has sufficient test coverage instead of waiting on the CI.

Generate coverage reports with `cmake --build build --target coverage`, it will generate HTML files under `build/coverage/` (main file is `index.html`).

## C++ coding guidelines
Expand Down

0 comments on commit 40f0b6a

Please sign in to comment.