Skip to content

v.compiler_tests.module_cache_fixture #

Helpers of the module_cache*_test.v files. Each of those is a test program of its own, so that the test runner can run them at the same time.

fn begin_module_cache_tests #

fn begin_module_cache_tests()

begin_module_cache_tests gives the tests of a program a VTMP of their own.

fn changed_module_cache_objects #

fn changed_module_cache_objects(before map[string]u64, after map[string]u64) []string

changed_module_cache_objects returns the names of the objects that before and after do not have in common.

fn compile_module_cache_project #

fn compile_module_cache_project(v3_bin string, cache_dir string, main_file string, output string)

compile_module_cache_project compiles a program with the module cache in cache_dir.

fn compile_module_cache_project_with_flags #

fn compile_module_cache_project_with_flags(v3_bin string, cache_dir string, main_file string, output string, flags []string)

compile_module_cache_project_with_flags is compile_module_cache_project with more flags.

fn create_module_cache_shipped_project #

fn create_module_cache_shipped_project(name string) string

create_module_cache_shipped_project makes an empty project for the test name. Explicit -b c retains a monolithic C file and disables the module cache. The fixtures use the default C backend and the system compiler (-cc cc). Native-cache fixtures must live in the shipped tree. User-supplied native headers deliberately bypass the cache because their dependencies are opaque. Windows limits paths to 260 characters, and the cache adds up to about 150 to the project directory, so the tree uses short names and a short hash of name.

fn create_module_cache_vroot #

fn create_module_cache_vroot(root string)

create_module_cache_vroot makes root a V root whose standard library is the one of this tree.

fn end_module_cache_tests #

fn end_module_cache_tests()

end_module_cache_tests removes what begin_module_cache_tests made.

fn module_cache_artifact #

fn module_cache_artifact(cache_dir string, prefix string, extension string) string

module_cache_artifact returns the path of a file in cache_dir whose name starts with prefix.

fn module_cache_compiler #

fn module_cache_compiler() string

module_cache_compiler returns the compiler that the tests run.

fn module_cache_object_hash #

fn module_cache_object_hash(path string) u64

module_cache_object_hash returns a hash of the contents of the file at path.

fn module_cache_object_hashes #

fn module_cache_object_hashes(cache_dir string) map[string]u64

module_cache_object_hashes returns the hashes of the module objects in cache_dir, by name.

fn module_cache_v_string_text #

fn module_cache_v_string_text(text string) string

module_cache_v_string_text spells text as a single-quoted V string literal of a cached header does: the backslashes of a Windows path are escaped too.

fn module_cache_vtmp_path #

fn module_cache_vtmp_path() string

module_cache_vtmp_path returns the temporary folder of this test program.

fn run_cached_module_cache_project #

fn run_cached_module_cache_project(v3_bin string, cache_dir string, main_file string) string

run_cached_module_cache_project compiles and runs a program with the module cache in cache_dir, and returns its output.

fn run_module_cache_binary #

fn run_module_cache_binary(path string) string

run_module_cache_binary runs the program at path and returns its output.

fn write_module_cache_file #

fn write_module_cache_file(root string, relative_path string, source string)

write_module_cache_file writes source to the file relative_path of the project root.