Cache configuration documentation

This commit is contained in:
Artur Jamro
2019-09-12 15:45:14 -07:00
committed by Dan Gohman
parent 1c22211d57
commit dde1c6ba58
18 changed files with 1238 additions and 233 deletions

View File

@@ -2,7 +2,7 @@ use wasmtime_environ::cache_init;
#[test]
fn test_cache_default_config_in_memory() {
let errors = cache_init::<&str>(true, None, false, None);
let errors = cache_init::<&str>(true, None, None);
assert!(
errors.is_empty(),
"This test loads config from the default location, if there's one. Make sure it's correct!"

View File

@@ -0,0 +1,7 @@
use wasmtime_environ::cache_init;
#[test]
fn test_cache_disabled() {
let errors = cache_init::<&str>(false, None, None);
assert!(errors.is_empty(), "Failed to disable cache system");
}

View File

@@ -20,7 +20,7 @@ fn test_cache_fail_calling_init_twice() {
);
fs::write(&config_path, config_content).expect("Failed to write test config file");
let errors = cache_init(true, Some(&config_path), false, None);
let errors = cache_init(true, Some(&config_path), None);
assert!(errors.is_empty());
let _errors = cache_init(true, Some(&config_path), false, None);
let _errors = cache_init(true, Some(&config_path), None);
}

View File

@@ -18,6 +18,6 @@ fn test_cache_fail_invalid_config() {
);
fs::write(&config_path, config_content).expect("Failed to write test config file");
let errors = cache_init(true, Some(&config_path), false, None);
let errors = cache_init(true, Some(&config_path), None);
assert!(!errors.is_empty());
}

View File

@@ -5,6 +5,6 @@ use wasmtime_environ::cache_init;
fn test_cache_fail_invalid_path_to_config() {
let dir = tempfile::tempdir().expect("Can't create temporary directory");
let config_path = dir.path().join("cache-config.toml"); // doesn't exist
let errors = cache_init(true, Some(&config_path), false, None);
let errors = cache_init(true, Some(&config_path), None);
assert!(!errors.is_empty());
}

View File

@@ -1,12 +1,13 @@
use tempfile;
use wasmtime_environ::cache_init;
use wasmtime_environ::cache_create_new_config;
#[test]
fn test_cache_write_default_config() {
let dir = tempfile::tempdir().expect("Can't create temporary directory");
let config_path = dir.path().join("cache-config.toml");
let errors = cache_init(true, Some(&config_path), true, None);
assert!(errors.is_empty());
let result = cache_create_new_config(Some(&config_path));
assert!(result.is_ok());
assert!(config_path.exists());
assert_eq!(config_path, result.unwrap());
}