From 88f6a0c1f70b6dc2b5d7c97d2580e1209b5ed5f0 Mon Sep 17 00:00:00 2001 From: Radek Date: Sun, 21 May 2023 14:00:14 +0200 Subject: [PATCH 1/2] spec include multifile tests --- src/spec/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/spec/mod.rs b/src/spec/mod.rs index c32cd54..a5f12b3 100644 --- a/src/spec/mod.rs +++ b/src/spec/mod.rs @@ -81,7 +81,8 @@ impl ParsedContract { fn contract_name_from_file(&self) -> String { let file_stem = self.path.file_stem().unwrap().to_str().unwrap().to_string(); if file_stem.ends_with(".t") { - file_stem[0..file_stem.len() - 2].to_string() // Slice off the ".t" at the end. + // Get everything before the first dot, slicing off .t, incl. cases for getting MyContract from MyContract.SomeFunction.t.sol + file_stem.split('.').next().unwrap().to_string() } else { file_stem } From da493623ae698d1b391cd8799e779f071a32c856 Mon Sep 17 00:00:00 2001 From: Matt Solomon Date: Tue, 23 May 2023 09:52:59 -0700 Subject: [PATCH 2/2] chore: tweak comment + cargo fmt --- src/spec/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/spec/mod.rs b/src/spec/mod.rs index a5f12b3..7d8dce3 100644 --- a/src/spec/mod.rs +++ b/src/spec/mod.rs @@ -81,7 +81,9 @@ impl ParsedContract { fn contract_name_from_file(&self) -> String { let file_stem = self.path.file_stem().unwrap().to_str().unwrap().to_string(); if file_stem.ends_with(".t") { - // Get everything before the first dot, slicing off .t, incl. cases for getting MyContract from MyContract.SomeFunction.t.sol + // Get everything before the first dot, slicing off `.t`. This enables support for both + // (1) putting all tests in MyContract.t.sol, and (2) splitting up tests across multiple + // files such as `MyContract.SomeFunction.t.sol`. file_stem.split('.').next().unwrap().to_string() } else { file_stem