Skip to content

Commit

Permalink
Merge pull request #249 from LimeChain/remove_suite_folder_modified_c…
Browse files Browse the repository at this point in the history
…heck

Remove the check if the suite folder is changed and just check each file
  • Loading branch information
dimitrovmaksim authored Dec 16, 2021
2 parents d549c3b + ee6c79d commit d9dca58
Showing 1 changed file with 10 additions and 26 deletions.
36 changes: 10 additions & 26 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,8 @@ impl Compiler {

pub fn execute(&self, name: String, entry: fs::DirEntry) -> CompileOutput {
let (in_files, out_file) = Compiler::get_paths_for(name.clone(), entry);
let mut suite_folder = String::new();

crate::TESTS_LOCATION.with(|path| {
suite_folder = format!("{}/{}", &*path.borrow(), name);
});

if !Path::new(&out_file).exists()
|| Compiler::is_source_modified(&suite_folder, &in_files, &out_file)
{
if !Path::new(&out_file).exists() || Compiler::is_source_modified(&in_files, &out_file) {
Log::Info(format!("Compiling {}...", name.bright_blue())).println();

self.compile(in_files, out_file)
Expand Down Expand Up @@ -169,32 +162,23 @@ impl Compiler {
}
}

fn is_source_modified(test_folder: &str, in_files: &[String], out_file: &str) -> bool {
fn is_source_modified(in_files: &[String], out_file: &str) -> bool {
let mut is_modified = false;

let wasm_modified = fs::metadata(out_file)
.unwrap_or_else(|err| panic!("{}", Log::Critical(err)))
.modified()
.unwrap();

let suite_folder_modified = fs::metadata(test_folder)
.unwrap_or_else(|err| panic!("{}", Log::Critical(err)))
.modified()
.unwrap();
for file in in_files {
let in_file_modified = fs::metadata(file)
.unwrap_or_else(|err| panic!("{}", Log::Critical(err)))
.modified()
.unwrap();

if suite_folder_modified > wasm_modified {
is_modified = true
} else {
for file in in_files {
let in_file_modified = fs::metadata(file)
.unwrap_or_else(|err| panic!("{}", Log::Critical(err)))
.modified()
.unwrap();

if in_file_modified > wasm_modified {
is_modified = true;
break;
}
if in_file_modified > wasm_modified {
is_modified = true;
break;
}
}

Expand Down

0 comments on commit d9dca58

Please sign in to comment.