[Test] Add ability to specify directive for test file

Rules of directives resolving:
- If no `MODULE` or `FILE` was declared in test then all directives
  belongs to module
- If `FILE` is declared, then all directives after it will belong to
  file until next `FILE` or `MODULE` directive will be declared
- All directives between `MODULE` and `FILE` directives belongs to module
- All directives before first `MODULE` are global and belongs to each
  declared module
This commit is contained in:
Dmitriy Novozhilov
2021-01-15 14:01:42 +03:00
committed by TeamCityServer
parent e17153fab9
commit 28cff22cd0
3 changed files with 34 additions and 6 deletions
@@ -43,7 +43,8 @@ class TestFile(
* isAdditional means that this file provided as addition to sources of testdata
* and there is no need to apply any handlers or preprocessors over it
*/
val isAdditional: Boolean
val isAdditional: Boolean,
val directives: RegisteredDirectives
) {
val name: String = relativePath.split("/").last()
}
@@ -26,7 +26,14 @@ abstract class AdditionalSourceProvider(val testServices: TestServices) {
}
protected fun File.toTestFile(): TestFile {
return TestFile(this.name, this.readText(), this, startLineNumberInOriginalFile = 0, isAdditional = true)
return TestFile(
this.name,
this.readText(),
originalFile = this,
startLineNumberInOriginalFile = 0,
isAdditional = true,
directives = RegisteredDirectives.Empty
)
}
}