Testing module

temp_dir

procedureextensionsince 0.28.0Source

A directory for this test's files. jacket test creates it and deletes it after a pass (--keep-temp keeps it); subtests share their test's directory.

Example
#import "File";

writes_a_file :: (t: *Test) {
    path := tprint("%/out.txt", temp_dir(t));
    expect(write_entire_file(path, "hi"));
} @test

This one is only checked to compile, not run.

temp_dir :: (t: *Test, loc := #caller_location) -> string

A directory for this test's files. jacket test creates it and deletes it after a pass (--keep-temp keeps it); subtests share their test's directory.

Parameters

t: *Test
the running test, or any of its subtests.
loc := #caller_location
where the call is written, shown if the test was given no directory. Leave the default.

Returns

string
Example
#import "File";

writes_a_file :: (t: *Test) {
    path := tprint("%/out.txt", temp_dir(t));
    expect(write_entire_file(path, "hi"));
} @test

This one is only checked to compile, not run.

See also