diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d4ac2c1..9995bbed 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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, @@ -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