pub struct TestSession { /* private fields */ }Expand description
One checker for a whole run: every test file gets its own fresh program state
(globals, package.loaded, module state), but modules are type-checked and
generated once and served to every file from the checker’s store.
Implementations§
Source§impl TestSession
impl TestSession
pub fn new( lint_spec: Option<&str>, lib: &str, filter: Option<&str>, opts: RunOptions, ) -> Result<Self>
Sourcepub fn checker(&self) -> &Htl
pub fn checker(&self) -> &Htl
The session’s checker (for Htl::executable_ranges on the sources a run touched).
Sourcepub fn run_file(&self, path: &Path) -> Result<FileReport>
pub fn run_file(&self, path: &Path) -> Result<FileReport>
Run one file in a fresh program state borrowing the session’s checker. The checker’s search path is restored afterwards so files do not see each other’s directories.
Sourcepub fn run_file_with(
&self,
path: &Path,
generated: Option<(&str, &CheckInfo)>,
preload: &[(String, String, PathBuf)],
) -> Result<(FileReport, Option<String>)>
pub fn run_file_with( &self, path: &Path, generated: Option<(&str, &CheckInfo)>, preload: &[(String, String, PathBuf)], ) -> Result<(FileReport, Option<String>)>
Run one file, reusing Lua the caller generated earlier.
generated is (the Lua, what checking it reported). Everything before the codegen
still happens — the searcher, the search path, the project and the config all have to
be in place before the code can execute — and everything after it happens as usual.
Only the check and the codegen are skipped.
The run itself is never reused, and this signature cannot express reusing it: a test has to run to say whether it passes.
Returns the report and, when this call generated the Lua rather than being handed it,
that Lua — so a caller keeping a cache has something to keep.
preload is (module name, its generated Lua, the file it came from) for modules
this file will require. Each one goes in front of the searcher, so requiring it does
not check and generate it during the run. A module not in the list still loads the
usual way; the list is an optimisation, never a restriction on what can be required.
Auto Trait Implementations§
impl !Freeze for TestSession
impl !RefUnwindSafe for TestSession
impl !Send for TestSession
impl !Sync for TestSession
impl !UnwindSafe for TestSession
impl Unpin for TestSession
impl UnsafeUnpin for TestSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more