This reverts commit a659dd821c484c4e0524d0a2bf88023dae5e259b.
This commit is contained in:
parent
620b2861e3
commit
ae2caff990
@ -221,6 +221,7 @@ where
|
|||||||
let mut ctr = 2;
|
let mut ctr = 2;
|
||||||
let filename = loop {
|
let filename = loop {
|
||||||
let lockfile = format!(".{file}.lafl_lock");
|
let lockfile = format!(".{file}.lafl_lock");
|
||||||
|
// try to create lockfile.
|
||||||
|
|
||||||
if OpenOptions::new()
|
if OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
@ -228,18 +229,15 @@ where
|
|||||||
.open(self.dir_path.join(lockfile))
|
.open(self.dir_path.join(lockfile))
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
break file;
|
break self.dir_path.join(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
file = format!("{file_orig}-{ctr}");
|
file = format!("{file_orig}-{ctr}");
|
||||||
ctr += 1;
|
ctr += 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
let file_path = self.dir_path.join(filename.clone());
|
let filename_str = filename.to_str().expect("Invalid Path");
|
||||||
let filename_str = file_path.to_str().expect("Invalid Path");
|
testcase.set_filename(filename_str.into());
|
||||||
testcase.set_filename(filename_str.into())?;
|
|
||||||
|
|
||||||
fs::remove_file(format!(".{filename}.lafl_lock"))?;
|
|
||||||
};
|
};
|
||||||
if self.meta_format.is_some() {
|
if self.meta_format.is_some() {
|
||||||
let mut filename = PathBuf::from(testcase.filename().as_ref().unwrap());
|
let mut filename = PathBuf::from(testcase.filename().as_ref().unwrap());
|
||||||
|
@ -8,8 +8,6 @@ use core::{
|
|||||||
option::Option,
|
option::Option,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "std")]
|
|
||||||
use std::fs;
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -146,53 +144,8 @@ where
|
|||||||
|
|
||||||
/// Set the filename
|
/// Set the filename
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(feature = "std")]
|
pub fn set_filename(&mut self, filename: String) {
|
||||||
pub fn set_filename(&mut self, filename: String) -> Result<(), Error> {
|
|
||||||
use std::fs::OpenOptions;
|
|
||||||
|
|
||||||
if self.filename.is_some() {
|
|
||||||
let f = self.filename.clone().unwrap();
|
|
||||||
let old_filename = f.as_str();
|
|
||||||
|
|
||||||
let new_filename = filename.as_str();
|
|
||||||
|
|
||||||
// Do operations below when new filename is specified
|
|
||||||
if old_filename.eq(new_filename) {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
let new_lock_filename = format!(".{new_filename}.lafl_lock");
|
|
||||||
|
|
||||||
// Try to create lock file for new testcases
|
|
||||||
if OpenOptions::new()
|
|
||||||
.create(true)
|
|
||||||
.write(true)
|
|
||||||
.open(&new_lock_filename)
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
return Err(Error::illegal_state(
|
|
||||||
"unable to create lock file for new testcase",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
fs::rename(old_filename, new_filename)?;
|
|
||||||
|
|
||||||
let old_metadata_filename = format!(".{old_filename}.metadata");
|
|
||||||
let new_metadata_filename = format!(".{new_filename}.metadata");
|
|
||||||
fs::rename(old_metadata_filename, new_metadata_filename)?;
|
|
||||||
|
|
||||||
fs::remove_file(&new_lock_filename)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.filename = Some(filename);
|
self.filename = Some(filename);
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[cfg(feature = "no_std")]
|
|
||||||
pub fn set_filename(&mut self, filename: String) -> Result<(), Error> {
|
|
||||||
self.filename = Some(filename);
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the execution time of the testcase
|
/// Get the execution time of the testcase
|
||||||
|
Loading…
x
Reference in New Issue
Block a user