mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-28 23:55:54 +00:00
tests: use tempfile::TempDir instead of env::temp_dir() + random number
Otherwise /tmp/test-<random> file would be left.
This commit is contained in:
parent
3b835df66e
commit
31e90bdede
1 changed files with 7 additions and 6 deletions
|
@ -72,16 +72,17 @@ impl Drop for FileLock {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::cmp::max;
|
||||
use std::{env, thread};
|
||||
use std::thread;
|
||||
|
||||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||
|
||||
use super::*;
|
||||
use crate::testutils;
|
||||
|
||||
#[test]
|
||||
fn lock_basic() {
|
||||
let number: u32 = rand::random();
|
||||
let lock_path = env::temp_dir().join(format!("test-{}.lock", number));
|
||||
let temp_dir = testutils::new_temp_dir();
|
||||
let lock_path = temp_dir.path().join("test.lock");
|
||||
assert!(!lock_path.exists());
|
||||
{
|
||||
let _lock = FileLock::lock(lock_path.clone());
|
||||
|
@ -92,9 +93,9 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn lock_concurrent() {
|
||||
let number: u32 = rand::random();
|
||||
let data_path = env::temp_dir().join(format!("test-{}", number));
|
||||
let lock_path = env::temp_dir().join(format!("test-{}.lock", number));
|
||||
let temp_dir = testutils::new_temp_dir();
|
||||
let data_path = temp_dir.path().join("test");
|
||||
let lock_path = temp_dir.path().join("test.lock");
|
||||
let mut data_file = OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
|
|
Loading…
Reference in a new issue