From fe66aa92e429ce88f115ef7fe3b4f0beb085b5e6 Mon Sep 17 00:00:00 2001 From: Yelaman Yelmuratov Date: Sat, 18 May 2024 02:19:08 +0500 Subject: [PATCH] . r check current default path of VS code --- .../diff_tool/diff_tool_reporter.dart | 5 +- test/approval_test.dart | 63 ++++++++----------- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/lib/src/reporters/diff_tool/diff_tool_reporter.dart b/lib/src/reporters/diff_tool/diff_tool_reporter.dart index 7665e4d..b82cf4e 100644 --- a/lib/src/reporters/diff_tool/diff_tool_reporter.dart +++ b/lib/src/reporters/diff_tool/diff_tool_reporter.dart @@ -30,14 +30,15 @@ class DiffReporter implements Reporter { } if (e is ProcessException) { ApprovalLogger.exception(e, stackTrace: st); + final ProcessResult result = await Process.run('which', ['code']); + ApprovalLogger.log('Path to Visual Studio Code: ${result.stdout}'); throw ProcessException( 'Error during comparison via ${ide.name}. Please try check path to IDE. \n Current path: ${diffInfo.command}.', [diffInfo.arg], ); } throw IDEComparatorException( - message: - 'Error during comparison via ${ide.name}. Please try check path to IDE. \n Current path: ${diffInfo.command}.', + message: 'Error during comparison via ${ide.name}. Please try check path to IDE. \n Current path: ${diffInfo.command}.', exception: e, stackTrace: st, ); diff --git a/test/approval_test.dart b/test/approval_test.dart index 78cd49d..f50aee8 100644 --- a/test/approval_test.dart +++ b/test/approval_test.dart @@ -94,8 +94,7 @@ void main() { ); }); - test("Method «verify» must throw DoesntMatchException with error handling", - () { + test("Method «verify» must throw DoesntMatchException with error handling", () { expect( () => helper.verify( 'Hello W0rld', @@ -116,9 +115,7 @@ void main() { ApprovalLogger.log("$lines25 Group: Minor cases are starting $lines25"); }); - test( - 'Simulate file not found error during comparison. Must throw CommandLineComparatorException.', - () async { + test('Simulate file not found error during comparison. Must throw CommandLineComparatorException.', () async { const comparator = FileComparator(); // Setup: paths to non-existent files @@ -139,9 +136,7 @@ void main() { ); }); - test( - 'Simulate file not found error during comparison. Must throw IDEComparatorException.', - () async { + test('Simulate file not found error during comparison. Must throw IDEComparatorException.', () async { const reporter = DiffReporter(); // Setup: paths to non-existent files @@ -178,34 +173,30 @@ void main() { ); }); - if (Platform.isLinux) { - test( - 'Verify string with DiffReporter. Must throw IDEComparatorException.', - () async { - const reporter = DiffReporter( - customDiffInfo: LinuxDiffTools.visualStudioCode, - ); - - // Setup: paths to non-existent files - const nonExistentApprovedPath = - 'test/approved_files/approval_test.verify.approved.txt'; - const nonExistentReceivedPath = - 'test/approved_files/approval_test.verify.received.txt'; - - // Expect an exception to be thrown - expect( - () => reporter.report( - nonExistentApprovedPath, - nonExistentReceivedPath, - ), - throwsA(isA()), - ); - - ApprovalLogger.success( - "Test Passed: Successfully handled a file not found error during comparison.", - ); - }); - } + // if (Platform.isLinux) { + test('Verify string with DiffReporter. Must throw IDEComparatorException.', () async { + const reporter = DiffReporter( + customDiffInfo: LinuxDiffTools.visualStudioCode, + ); + + // Setup: paths to non-existent files + const nonExistentApprovedPath = 'test/approved_files/approval_test.verify.approved.txt'; + const nonExistentReceivedPath = 'test/approved_files/approval_test.verify.received.txt'; + + // Expect an exception to be thrown + expect( + () => reporter.report( + nonExistentApprovedPath, + nonExistentReceivedPath, + ), + throwsA(isA()), + ); + + ApprovalLogger.success( + "Test Passed: Successfully handled a file not found error during comparison.", + ); + }); + // } test('Verify string with scrubber', () { helper.verify(