-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
. t coverage code 97% by tests, need to add tests for diff tool: wind…
…ows and linux, android studio for mac
- Loading branch information
1 parent
14c3d8f
commit aec417e
Showing
13 changed files
with
118 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
part of '../../approval_tests.dart'; | ||
|
||
class FilePathExtractor { | ||
final IStackTraceFetcher _stackTraceFetcher; | ||
|
||
const FilePathExtractor({ | ||
IStackTraceFetcher? stackTraceFetcher, | ||
}) : _stackTraceFetcher = stackTraceFetcher ?? const StackTraceFetcher(); | ||
|
||
String get filePath { | ||
try { | ||
final stackTraceString = _stackTraceFetcher.currentStackTrace; | ||
final uriRegExp = RegExp(r'file:\/\/\/([^\s:]+)'); | ||
|
||
final match = uriRegExp.firstMatch(stackTraceString); | ||
|
||
if (match != null) { | ||
final filePath = Uri.tryParse('file:///${match.group(1)!}'); | ||
return filePath!.toFilePath(); | ||
} else { | ||
throw FileNotFoundException( | ||
message: 'File not found in stack trace', | ||
stackTrace: StackTrace.current, | ||
); | ||
} | ||
} catch (e) { | ||
rethrow; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
part of '../../../approval_tests.dart'; | ||
|
||
/// Interface for fetching the current stack trace. | ||
abstract interface class IStackTraceFetcher { | ||
String get currentStackTrace; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
part of '../../../approval_tests.dart'; | ||
|
||
/// A class that provides the current stack trace. | ||
final class StackTraceFetcher implements IStackTraceFetcher { | ||
const StackTraceFetcher(); | ||
|
||
@override | ||
String get currentStackTrace => StackTrace.current.toString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
part of '../../approval_tests.dart'; | ||
|
||
class FileNotFoundException implements Exception { | ||
final String message; | ||
|
||
final StackTrace? stackTrace; | ||
|
||
FileNotFoundException({ | ||
required this.message, | ||
this.stackTrace, | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
part of '../approval_test.dart'; | ||
|
||
/// `FakeStackTraceFetcher` is a fake implementation of [IStackTraceFetcher] that needs to be used in tests. | ||
class FakeStackTraceFetcher implements IStackTraceFetcher { | ||
final String stackTrace; | ||
|
||
const FakeStackTraceFetcher(this.stackTrace); | ||
|
||
@override | ||
String get currentStackTrace => stackTrace; | ||
} |