From a9b14f1454d15d847254373b5708ff21fd4f8cfc Mon Sep 17 00:00:00 2001 From: danglotb Date: Fri, 1 Mar 2019 13:02:44 +0100 Subject: [PATCH] fix: skipping parsing command line in case of empty string or white space [hotfix] --- .../stamp_project/testrunner/EntryPoint.java | 23 ++++++++++-------- .../testrunner/runner/ParserOptions.java | 3 +++ .../testrunner/runner/ParserOptions.class | Bin 5429 -> 5495 bytes 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/eu/stamp_project/testrunner/EntryPoint.java b/src/main/java/eu/stamp_project/testrunner/EntryPoint.java index a56eeb8b..0e1575f1 100644 --- a/src/main/java/eu/stamp_project/testrunner/EntryPoint.java +++ b/src/main/java/eu/stamp_project/testrunner/EntryPoint.java @@ -183,11 +183,13 @@ public static TestResult runTests(String classpath, String[] fullQualifiedNameOf ParserOptions.FLAG_fullQualifiedNameOfTestClassToRun, String.join(ConstantsHelper.PATH_SEPARATOR, fullQualifiedNameOfTestClasses), methodNames.length == 0 ? "" - : ParserOptions.FLAG_testMethodNamesToRun + ConstantsHelper.WHITE_SPACE - + String.join(ConstantsHelper.PATH_SEPARATOR, methodNames), + : (ParserOptions.FLAG_testMethodNamesToRun + ConstantsHelper.WHITE_SPACE + + String.join(ConstantsHelper.PATH_SEPARATOR, methodNames)), EntryPoint.blackList.isEmpty() ? "" : (ParserOptions.FLAG_blackList + ConstantsHelper.WHITE_SPACE - + String.join(ConstantsHelper.PATH_SEPARATOR, EntryPoint.blackList)) }); + + String.join(ConstantsHelper.PATH_SEPARATOR, EntryPoint.blackList)) + } + ); return EntryPoint.runTests(javaCommand); } @@ -264,10 +266,11 @@ public static Coverage runCoverage(String classpath, String targetProjectClasses EntryPoint.JACOCO_RUNNER_QUALIFIED_NAME, ParserOptions.FLAG_pathToCompiledClassesOfTheProject, targetProjectClasses, ParserOptions.FLAG_fullQualifiedNameOfTestClassToRun, String.join(ConstantsHelper.PATH_SEPARATOR, fullQualifiedNameOfTestClasses), - methodNames.length == 0 ? "" : ParserOptions.FLAG_testMethodNamesToRun, - String.join(ConstantsHelper.PATH_SEPARATOR, methodNames), - EntryPoint.blackList.isEmpty() ? "" - : (ParserOptions.FLAG_blackList + ConstantsHelper.WHITE_SPACE + methodNames.length == 0 ? "" : + (ParserOptions.FLAG_testMethodNamesToRun + ConstantsHelper.WHITE_SPACE + + String.join(ConstantsHelper.PATH_SEPARATOR, methodNames)), + EntryPoint.blackList.isEmpty() ? "" : + (ParserOptions.FLAG_blackList + ConstantsHelper.WHITE_SPACE + String.join(ConstantsHelper.PATH_SEPARATOR, EntryPoint.blackList)), EntryPoint.jUnit5Mode ? ParserOptions.FLAG_isJUnit5 : "" }); return EntryPoint.runCoverage(javaCommand); @@ -351,8 +354,8 @@ public static CoveragePerTestMethod runCoveragePerTestMethods(String classpath, EntryPoint.JACOCO_RUNNER_PER_TEST_QUALIFIED_NAME, ParserOptions.FLAG_pathToCompiledClassesOfTheProject, targetProjectClasses, ParserOptions.FLAG_fullQualifiedNameOfTestClassToRun, String.join(ConstantsHelper.PATH_SEPARATOR, fullQualifiedNameOfTestClasses), - methodNames.length == 0 ? "" : ParserOptions.FLAG_testMethodNamesToRun, - String.join(ConstantsHelper.PATH_SEPARATOR, methodNames), + methodNames.length == 0 ? "" : ParserOptions.FLAG_testMethodNamesToRun + ConstantsHelper.WHITE_SPACE + + String.join(ConstantsHelper.PATH_SEPARATOR, methodNames), EntryPoint.blackList.isEmpty() ? "" : (ParserOptions.FLAG_blackList + ConstantsHelper.WHITE_SPACE + String.join(ConstantsHelper.PATH_SEPARATOR, EntryPoint.blackList)), @@ -429,7 +432,7 @@ private static void runGivenCommandLine(String commandLine) throws TimeoutExcept /** * This method redirect Process IO to given destination using pipes - * + * * @param src * process input stream * @param dest diff --git a/src/main/java/eu/stamp_project/testrunner/runner/ParserOptions.java b/src/main/java/eu/stamp_project/testrunner/runner/ParserOptions.java index 20b832ab..0fe77fc4 100644 --- a/src/main/java/eu/stamp_project/testrunner/runner/ParserOptions.java +++ b/src/main/java/eu/stamp_project/testrunner/runner/ParserOptions.java @@ -40,6 +40,9 @@ public static ParserOptions parse(String[] args) { case FLAG_isJUnit5: parserOptions.isJUnit5 = true; break; + case " ": + case "": + break; default: System.err.println(String.format("[ERROR]: %s is not a supported command line options", args[i])); usage(); diff --git a/src/main/resources/runner-classes/eu/stamp_project/testrunner/runner/ParserOptions.class b/src/main/resources/runner-classes/eu/stamp_project/testrunner/runner/ParserOptions.class index ecd3bce9eda47d01b126c34cb0f7d10a2b4c63d6..428da275a8296b547307e5e65fe41dcf41010fc3 100644 GIT binary patch delta 1154 zcmZ9L-ES0C7{-5RXV{qzr5~reE$x=JEZuH9(7MujfpYE z8{4IP$v35=e8fcJ)c|@S3%g4o|)%;&-2Wg^PY2_ znUepvzqGsHGGB+wLLI#nJO(*x=%NY7OgO%p6P$E7Wyt3yoUY>o&bXZQgq(9Y@6pYi z%LS7!nt3icEV*2ES$2tBzHs@{JiFpyG3RjA;hIOtoX7QV9wjXWcONDHwC={ZZ!$oMUKrsO<`Ebq#F_b#sL}O)@%d z-9(E6vuye-s`;ASLo0?Gte)FX{YU!_xeP>YH7u^RMfOuP^1PICayG57A_hi z&<@`qD3o5m>O#YUOrkDy$c#0HgdK^xFwuoEVduhyCa!RWdhRfZP4CM&=l=iqzH{F_ z|MUJ1tKs5PrDlBQn<=mmFhm`mwA?A{PPcG|vmWOxIB(sBW?ti>&)b23OCFa4a?JU> zW8=Fv&lQiWK8rrre3pES&wF<5{Q$>q{J`TwkBF&T&z=dm`z%kiuDG8rDc-du$y&1lYGosC&Lx%7277ZPwcSR(I`BdP~AJK zw3T_e0V?Pk=_;8rGi#`9nX#zC#s_bG!=?ncX|K{zrVzPRI?HrbD0S&>_ZH3(N9u5B zg=7tHh0StO`JdmSFXdc^XT(pT#kb4TL7q+q>EcH=^Q*{nSC~KP;V%jb`jo?fYNx2W z*sAh`s=$yMAy#8_stF!uMl$6kZ?D?I=m8Fruww8mV|GEdKgS`F>Ulvur0&z}aai4F z!edso%4jL9(|VI<@;X<_9r>Cq)1l7S=&8^v{)Nzr(xYAL`c~5-PJ`}WO^ZkkdSEpz zVm0XEYFb2V(1S9YZJb#_g*CQH@xGF;PSi^_N~_FwNw4oF%OfJ_i2Nm^?2&s;vRCf? z7%wu;D@^c)Fbh1+MV?@ZCrvsX9SlPqiP)iYiy=|C5wqd9#B%9}M9I(*8UH^pCw&da zqn~J7do?+zF_=JWbUQg)Mc|j6X}k% g8?KtunVq`xi#6$txs!=p+mz;BW>Rf5quIUx0X%oZyZ`_I