From 087d886c60846cbb02d3a2d327c899b7105fc2cf Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Sun, 9 Jul 2023 12:54:43 +0200 Subject: [PATCH] test more invalid inputs in autofix cli --- src/dscanner/analysis/run.d | 2 +- tests/it.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dscanner/analysis/run.d b/src/dscanner/analysis/run.d index 425fde1..7d40d51 100644 --- a/src/dscanner/analysis/run.d +++ b/src/dscanner/analysis/run.d @@ -616,7 +616,7 @@ private struct UserSelect throw new Exception("Selected option number out of range."); return item; } - catch (ConvException e) + catch (Exception e) { writeln("Invalid selection, try again. ", e.message); } diff --git a/tests/it.sh b/tests/it.sh index 503bfb7..6271e69 100755 --- a/tests/it.sh +++ b/tests/it.sh @@ -27,6 +27,10 @@ echo '2. test no changes for simple enter pressing' cp -v it/autofix_cli/source.d it/autofix_cli/test.d printf "\n" | ../bin/dscanner fix it/autofix_cli/test.d diff it/autofix_cli/test.d it/autofix_cli/source.d +echo '2.1. test no changes entering 0' +cp -v it/autofix_cli/source.d it/autofix_cli/test.d +printf "0\n" | ../bin/dscanner fix it/autofix_cli/test.d +diff it/autofix_cli/test.d it/autofix_cli/source.d echo '3. test change applies automatically with --applySingle' cp -v it/autofix_cli/source.d it/autofix_cli/test.d ../bin/dscanner fix --applySingle it/autofix_cli/test.d | grep -F 'Writing changes to it/autofix_cli/test.d' @@ -35,4 +39,8 @@ echo '4. test change apply when entering "1"' cp -v it/autofix_cli/source.d it/autofix_cli/test.d printf "1\n" | ../bin/dscanner fix it/autofix_cli/test.d | grep -F 'Writing changes to it/autofix_cli/test.d' diff it/autofix_cli/test.d it/autofix_cli/fixed.d +echo '5. test invalid selection reasks what to apply' +cp -v it/autofix_cli/source.d it/autofix_cli/test.d +printf "2\n-1\n1000\na\n1\n" | ../bin/dscanner fix it/autofix_cli/test.d | grep -F 'Writing changes to it/autofix_cli/test.d' +diff it/autofix_cli/test.d it/autofix_cli/fixed.d