File tree Expand file tree Collapse file tree 2 files changed +44
-7
lines changed
test/WebJobs.Script.Tests Expand file tree Collapse file tree 2 files changed +44
-7
lines changed Original file line number Diff line number Diff line change @@ -174,16 +174,28 @@ public void NotifyDebug()
174
174
// file. However, we leave this here for assurances.
175
175
LastDebugNotify = DateTime . UtcNow ;
176
176
177
- // create or update the debug sentinel file to trigger a
178
- // debug timeout update across all instances
179
- string debugSentinelFileName = Path . Combine ( ScriptConfig . RootLogPath , "Host" , ScriptConstants . DebugSentinelFileName ) ;
180
- if ( ! File . Exists ( debugSentinelFileName ) )
177
+ try
181
178
{
182
- File . WriteAllText ( debugSentinelFileName , "This is a system managed marker file used to control runtime debug mode behavior." ) ;
179
+ // create or update the debug sentinel file to trigger a
180
+ // debug timeout update across all instances
181
+ string debugSentinelFileName = Path . Combine ( ScriptConfig . RootLogPath , "Host" , ScriptConstants . DebugSentinelFileName ) ;
182
+ if ( ! File . Exists ( debugSentinelFileName ) )
183
+ {
184
+ File . WriteAllText ( debugSentinelFileName , "This is a system managed marker file used to control runtime debug mode behavior." ) ;
185
+ }
186
+ else
187
+ {
188
+ File . SetLastWriteTimeUtc ( debugSentinelFileName , DateTime . UtcNow ) ;
189
+ }
183
190
}
184
- else
191
+ catch ( Exception ex )
185
192
{
186
- File . SetLastWriteTimeUtc ( debugSentinelFileName , DateTime . UtcNow ) ;
193
+ // best effort
194
+ TraceWriter . Error ( "Unable to update the debug sentinel file." , ex ) ;
195
+ if ( ex . IsFatal ( ) )
196
+ {
197
+ throw ;
198
+ }
187
199
}
188
200
}
189
201
Original file line number Diff line number Diff line change @@ -149,6 +149,31 @@ public void NotifyDebug_UpdatesDebugMarkerFileAndTimestamp()
149
149
Assert . True ( host . LastDebugNotify > lastDebugNotify ) ;
150
150
}
151
151
152
+ [ Fact ]
153
+ public void NotifyDebug_HandlesExceptions ( )
154
+ {
155
+ ScriptHost host = _fixture . Host ;
156
+ string debugSentinelFileName = Path . Combine ( host . ScriptConfig . RootLogPath , "Host" , ScriptConstants . DebugSentinelFileName ) ;
157
+
158
+ try
159
+ {
160
+ host . NotifyDebug ( ) ;
161
+ Assert . True ( host . InDebugMode ) ;
162
+
163
+ var attributes = File . GetAttributes ( debugSentinelFileName ) ;
164
+ attributes |= FileAttributes . ReadOnly ;
165
+ File . SetAttributes ( debugSentinelFileName , attributes ) ;
166
+ Assert . True ( host . InDebugMode ) ;
167
+
168
+ host . NotifyDebug ( ) ;
169
+ }
170
+ finally
171
+ {
172
+ File . SetAttributes ( debugSentinelFileName , FileAttributes . Normal ) ;
173
+ File . Delete ( debugSentinelFileName ) ;
174
+ }
175
+ }
176
+
152
177
[ Fact ]
153
178
public void Version_ReturnsAssemblyVersion ( )
154
179
{
You can’t perform that action at this time.
0 commit comments