Skip to content

Commit

Permalink
[SCM-912] Unify messages if SCM system command is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-o committed Sep 10, 2018
1 parent 0b4dbcc commit 5ec25fd
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ protected void setUp()

if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVNADMIN_COMMAND_LINE
+ "' is not a system command. Ignored setUp." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp" );
return;
}

Expand All @@ -79,8 +78,7 @@ public void testBranch()
{
if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVN_COMMAND_LINE
+ "' is not a system command. Ignored " + getName() + "." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() );
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ protected void setUp()

if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVNADMIN_COMMAND_LINE
+ "' is not a system command. Ignored setUp." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp" );
return;
}

Expand All @@ -61,8 +60,7 @@ public void testChangeLog()
{
if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVN_COMMAND_LINE
+ "' is not a system command. Ignored " + getName() + "." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() );
return;
}

Expand All @@ -84,8 +82,7 @@ public void testChangeLogWithParameters()
{
if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVN_COMMAND_LINE
+ "' is not a system command. Ignored " + getName() + "." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() );
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ public void testSkipCheckoutWithConnectionUrl()
{
if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVNADMIN_COMMAND_LINE
+ "' is not a system command. Ignored " + getName() + "." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName() );
return;
}

FileUtils.forceDelete( checkoutDir );

SvnScmTestUtils.initializeRepository( repository );

CheckoutMojo mojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile(
Expand All @@ -100,7 +99,7 @@ public void testSkipCheckoutWithoutConnectionUrl()
throws Exception
{
FileUtils.forceDelete( checkoutDir );

checkoutDir.mkdirs();
CheckoutMojo mojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile(
"src/test/resources/mojos/checkout/checkoutWithoutConnectionUrl.xml" ) );
Expand All @@ -121,7 +120,7 @@ public void testUseExport()
throws Exception
{
FileUtils.forceDelete( checkoutDir );

checkoutDir.mkdirs();

CheckoutMojo mojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile(
Expand All @@ -132,14 +131,14 @@ public void testUseExport()
mojo.execute();

assertTrue( checkoutDir.listFiles().length > 0 );
assertFalse( new File( checkoutDir, ".svn" ).exists() );
assertFalse( new File( checkoutDir, ".svn" ).exists() );
}

public void testExcludeInclude()
throws Exception
{
FileUtils.forceDelete( checkoutDir );

checkoutDir.mkdirs();

SvnScmTestUtils.initializeRepository( repository );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void testShouldInvokeP4Delete()

if ( !ScmTestCase.isSystemCmd( "p4" ) )
{
System.out.println( "'skip test as p4 is not available" );
ScmTestCase.printSystemCmdUnavail( "p4", getName() );
return;
}

Expand Down Expand Up @@ -73,7 +73,7 @@ public void testShouldFailToInvokeP4Delete()
{
if ( !ScmTestCase.isSystemCmd( "p4" ) )
{
System.out.println( "'skip test as p4 is not available" );
ScmTestCase.printSystemCmdUnavail( "p4", getName() );
return;
}
String testConfig = "src/test/resources/mojos/remove/removeWithPerforceNoIncludes.xml";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public void testStatusMojo()
{
if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVN_COMMAND_LINE
+ "' is not a system command. Ignored " + getName() + "." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() );
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ protected void setUp()

if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVNADMIN_COMMAND_LINE
+ "' is not a system command. Ignored setUp." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, "setUp" );
return;
}

Expand All @@ -79,8 +78,7 @@ public void testTag()
{
if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVNADMIN_COMMAND_LINE
+ "' is not a system command. Ignored " + getName() + "." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName() );
return;
}

Expand All @@ -96,8 +94,7 @@ public void testTag()

if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVN_COMMAND_LINE
+ "' is not a system command. Ignored " + getName() + "." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() );
return;
}

Expand Down Expand Up @@ -127,8 +124,7 @@ public void testTagWithTimestamp()
{
if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVN_COMMAND_LINE
+ "' is not a system command. Ignored " + getName() + "." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVN_COMMAND_LINE, getName() );
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public void testSkipCheckoutWithConnectionUrl()
{
if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) )
{
System.err.println( "'" + SvnScmTestUtils.SVNADMIN_COMMAND_LINE
+ "' is not a system command. Ignored " + getName() + "." );
ScmTestCase.printSystemCmdUnavail( SvnScmTestUtils.SVNADMIN_COMMAND_LINE, getName() );
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public void testPerforceInfo()

PerforceScmProviderRepository p4Repo = (PerforceScmProviderRepository) repo.getProviderRepository();

if ( !ScmTestCase.isSystemCmd( "p4" ) )
{
ScmTestCase.printSystemCmdUnavail( "p4", getName() );
return;
}

PerforceScmProvider prov = new PerforceScmProvider();
PerforceTagCommand cmd = new PerforceTagCommand();
cmd.setLogger( prov.getLogger() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* under the License.
*/

import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
import org.apache.maven.scm.command.changelog.ChangeLogSet;
import org.apache.maven.scm.manager.ScmManager;
Expand Down Expand Up @@ -77,8 +78,7 @@ private void testChangeLog( Date startDate, Date endDate, int changeLogSize, Str
{
if ( !isSystemCmd( CvsScmTestUtils.CVS_COMMAND_LINE ) )
{
System.err.println( "'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored "
+ getName() + "." );
ScmTestCase.printSystemCmdUnavail( CvsScmTestUtils.CVS_COMMAND_LINE, getName() );
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.maven.scm.ScmFile;
import org.apache.maven.scm.ScmFileStatus;
import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.provider.cvslib.AbstractCvsScmTest;
Expand Down Expand Up @@ -51,8 +52,7 @@ public void testCheckOutWithoutTag()
{
if ( !isSystemCmd( CvsScmTestUtils.CVS_COMMAND_LINE ) )
{
System.err.println( "'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored "
+ getName() + "." );
ScmTestCase.printSystemCmdUnavail( CvsScmTestUtils.CVS_COMMAND_LINE, getName() );
return;
}

Expand Down Expand Up @@ -86,8 +86,7 @@ public void testCheckOutWithTag()
{
if ( !isSystemCmd( CvsScmTestUtils.CVS_COMMAND_LINE ) )
{
System.err.println( "'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored "
+ getName() + "." );
ScmTestCase.printSystemCmdUnavail( CvsScmTestUtils.CVS_COMMAND_LINE, getName() );
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.maven.scm.ScmFile;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmFileStatus;
import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.command.update.UpdateScmResult;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.provider.cvslib.AbstractCvsScmTest;
Expand Down Expand Up @@ -84,8 +85,7 @@ public void testCvsUpdate()
{
if ( !isSystemCmd( CvsScmTestUtils.CVS_COMMAND_LINE ) )
{
System.err.println(
"'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored " + getName() + "." );
ScmTestCase.printSystemCmdUnavail( CvsScmTestUtils.CVS_COMMAND_LINE, getName() );
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void testCheckinNoBranch()
{
if ( !ScmTestCase.isSystemCmd( "git" ) )
{
System.out.println( "Skip test which requires Git native executable to be in PATH" );
ScmTestCase.printSystemCmdUnavail( "git", getName() );
return;
}
File repo_orig = new File( "src/test/resources/repository_no_branch" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void testCheckinAfterRename() throws Exception {

if ( !ScmTestCase.isSystemCmd( "git" ) )
{
System.out.println( "Skip test which requires Git native executable to be in PATH" );
ScmTestCase.printSystemCmdUnavail( "git", getName() );
return;
}

Expand Down Expand Up @@ -145,7 +145,7 @@ public void testCheckinWithFileSet() throws Exception {

if ( !ScmTestCase.isSystemCmd( "git" ) )
{
System.out.println( "Skip test which requires Git native executable to be in PATH" );
ScmTestCase.printSystemCmdUnavail( "git", getName() );
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testCheckoutNoBranch()
{
if ( !ScmTestCase.isSystemCmd( "git" ) )
{
System.out.println( "Skip test which requires Git native executable to be in PATH" );
ScmTestCase.printSystemCmdUnavail( "git", getName() );
return;
}
CheckOutScmResult result = checkoutRepo();
Expand All @@ -71,7 +71,7 @@ public void testDoubleCheckoutNoBranch()
{
if ( !ScmTestCase.isSystemCmd( "git" ) )
{
System.out.println( "Skip test which requires Git native executable to be in PATH" );
ScmTestCase.printSystemCmdUnavail( "git", getName() );
return;
}
CheckOutScmResult result = checkoutRepo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,9 @@ public static boolean isSystemCmd( String cmd )
return false;
}
}

public static void printSystemCmdUnavail( String cmd, String testName )
{
System.err.printf( "'%s' is not a system command. Ignored %s.%n", cmd, testName );
}
}

0 comments on commit 5ec25fd

Please sign in to comment.