tugger_common/
testutil.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5use {once_cell::sync::Lazy, std::path::PathBuf};
6
7pub static DEFAULT_TEMP_DIR: Lazy<tempfile::TempDir> = Lazy::new(|| {
8    tempfile::Builder::new()
9        .prefix("tugger-test")
10        .tempdir()
11        .expect("unable to create temporary directory")
12});
13
14pub static DEFAULT_DOWNLOAD_DIR: Lazy<PathBuf> = Lazy::new(|| {
15    let p = if let Ok(manifest_dir) = std::env::var("OUT_DIR") {
16        PathBuf::from(manifest_dir).join("tugger-files")
17    } else {
18        DEFAULT_TEMP_DIR.path().join("tugger-files")
19    };
20
21    std::fs::create_dir_all(&p).expect("unable to create download directory");
22
23    p
24});