Skip to content

Commit 92441fe

Browse files
Fixing IncludesManager not reflecting properly on missing includes
1 parent 86be1d1 commit 92441fe

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

Src/Tests/IncludeManagerTest.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,6 @@ int main(int argc, char** argv)
711711
//Setup timestamps
712712
const auto recordTime = ghc::filesystem::file_time_type::clock::now();
713713
const auto sourceTime = recordTime - std::chrono::seconds(1);
714-
const auto includeTime = recordTime + std::chrono::seconds(1);
715714

716715
//Mock source file time
717716
std::shared_ptr<OverrideResult> sourceTimeResult = CreateOverrideResult();
@@ -736,17 +735,13 @@ int main(int argc, char** argv)
736735
CO_SETUP_OVERRIDE (OverrideInstance, Mock_exists)
737736
.WhenCalledWith<const ghc::filesystem::path&,
738737
CO_ANY_TYPE>(includePaths[1], CO_ANY)
739-
.Returns<bool>(true)
740-
.Times(1)
741738
.AssignResult(include2ExistsResult);
742739

743740
//Mock second include file time
744741
std::shared_ptr<OverrideResult> include2TimeResult = CreateOverrideResult();
745742
CO_SETUP_OVERRIDE (OverrideInstance, Mock_last_write_time)
746743
.WhenCalledWith<const ghc::filesystem::path&,
747744
CO_ANY_TYPE>(includePaths[1], CO_ANY)
748-
.Returns<ghc::filesystem::file_time_type>(includeTime)
749-
.Times(1)
750745
.AssignResult(include2TimeResult);
751746

752747
std::vector<ghc::filesystem::path> includes = { includePaths[0], includePaths[1] };
@@ -759,10 +754,10 @@ int main(int argc, char** argv)
759754
sourceTimeResult->GetSucceedCount(), 1);
760755
ssTEST_OUTPUT_ASSERT( "First include exists should be checked",
761756
include1ExistsResult->GetSucceedCount(), 1);
762-
ssTEST_OUTPUT_ASSERT( "Second include exists should be checked",
763-
include2ExistsResult->GetSucceedCount(), 1);
764-
ssTEST_OUTPUT_ASSERT( "Second include time should be checked",
765-
include2TimeResult->GetSucceedCount(), 1);
757+
ssTEST_OUTPUT_ASSERT( "Second include exists should not be checked",
758+
include2ExistsResult->GetStatusCount(), 0);
759+
ssTEST_OUTPUT_ASSERT( "Second include time should not be checked",
760+
include2TimeResult->GetStatusCount(), 0);
766761
};
767762

768763
ssTEST("GetRecordPath Should Generate Valid And Unique Paths")

Src/runcpp2/IncludeManager.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,20 @@ namespace runcpp2
123123

124124
for(const ghc::filesystem::path& include : includes)
125125
{
126-
if(ghc::filesystem::exists(include, e))
126+
if(!ghc::filesystem::exists(include, e))
127127
{
128-
ghc::filesystem::file_time_type includeTime =
129-
ghc::filesystem::last_write_time(include, e);
130-
if(includeTime > recordTime)
131-
{
132-
ssLOG_DEBUG("Include time for " << include.string() <<
133-
" is newer than record time");
134-
return true;
135-
}
128+
ssLOG_DEBUG("Include file does not exist: " << include.string());
129+
return true;
130+
}
131+
132+
ghc::filesystem::file_time_type includeTime =
133+
ghc::filesystem::last_write_time(include, e);
134+
135+
if(includeTime > recordTime)
136+
{
137+
ssLOG_DEBUG("Include time for " << include.string() <<
138+
" is newer than record time");
139+
return true;
136140
}
137141
}
138142

0 commit comments

Comments
 (0)