Author: timotei
Date: Tue Jul 26 17:43:22 2011
New Revision: 50451
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50451&view=rev
Log:
eclipse plugin: Create a Test Suite to handle all tests
and add the tests for data/ directory
Added:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/WMLTestsSuite.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLFilesTests.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokensTests.java
- copied, changed from r50450,
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokens.java
Removed:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokens.java
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/WMLTests.java
Modified: trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/WMLTests.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/WMLTests.java?rev=50451&r1=50450&r2=50451&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/WMLTests.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/WMLTests.java Tue Jul
26 17:43:22 2011
@@ -54,6 +54,17 @@
tokenDefProvider = get( ITokenDefProvider.class );
parser = get( IParser.class );
grammar = ( WMLGrammarAccess ) getGrammarAccess( );
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown( );
+
+ lexer = null;
+ tokenDefProvider = null;
+ parser = null;
+ grammar = null;
}
/**
Added: trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/WMLTestsSuite.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/WMLTestsSuite.java?rev=50451&view=auto
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/WMLTestsSuite.java
(added)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/WMLTestsSuite.java
Tue Jul 26 17:43:22 2011
@@ -1,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by Timotei Dolean <[email protected]>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+
*******************************************************************************/
+package org.wesnoth.tests;
+
+import junit.framework.TestSuite;
+
+import org.junit.Test;
+import org.wesnoth.tests.grammar.WMLFilesTests;
+import org.wesnoth.tests.grammar.WMLGrammarTokensTests;
+
+public class WMLTestsSuite
+{
+ @Test
+ public static TestSuite suite( )
+ {
+ TestSuite suite = new TestSuite( );
+
+ // grammar
+ suite.addTestSuite( WMLFilesTests.class );
+ suite.addTestSuite( WMLGrammarTokensTests.class );
+
+ return suite;
+ }
+}
Added:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLFilesTests.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLFilesTests.java?rev=50451&view=auto
==============================================================================
---
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLFilesTests.java
(added)
+++
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLFilesTests.java
Tue Jul 26 17:43:22 2011
@@ -1,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by Timotei Dolean <[email protected]>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+
*******************************************************************************/
+package org.wesnoth.tests.grammar;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+
+import org.eclipse.xtext.parser.IParseResult;
+import org.junit.Ignore;
+import org.wesnoth.tests.WMLTests;
+import org.wesnoth.utils.StringUtils;
+
+/**
+ * This tests test the data/core directory and each campaign
+ */
+public class WMLFilesTests extends WMLTests
+{
+ protected String dataPath_ = "";
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp( );
+
+ // get the wesnoth data path from the user
+ dataPath_ = System.getProperty( "wesnothDataDir" );
+ if ( StringUtils.isNullOrEmpty( dataPath_ ) || ! new File( dataPath_
).exists( ) )
+ throw new Exception( "Please set the wesnoth data dir before
testing!." );
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown( );
+ dataPath_ = null;
+ }
+
+ public void testCoreFiles() throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/core/" );
+ }
+
+ public void testCampaignAOI( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/An_Orcish_Incursion/" );
+ }
+
+ public void testCampaignDW( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Dead_Water/" );
+ }
+
+ public void testCampaignDM( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Delfadors_Memoirs/" );
+ }
+
+ public void testCampaignDID( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Descent_Into_Darkness/" );
+ }
+
+ public void testCampaignEI( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Eastern_Invasion/" );
+ }
+
+ public void testCampaignHttT( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Heir_To_The_Throne/" );
+ }
+
+ public void testCampaignLoW( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Legend_of_Wesmere/" );
+ }
+
+ public void testCampaignLiberty( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Liberty/" );
+ }
+
+ public void testCampaignNR( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Northern_Rebirth/" );
+ }
+
+ public void testCampaignSoF( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Sceptre_of_Fire/" );
+ }
+
+ public void testCampaignSotBT( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Son_Of_The_Black_Eye/" );
+ }
+
+ public void testCampaignTest( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/test_campaign/" );
+ }
+
+ public void testCampaignTHT( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/The_Hammer_of_Thursagan/" );
+ }
+
+ public void testCampaignTRoW( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/The_Rise_Of_Wesnoth/" );
+ }
+
+ public void testCampaignTSG( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/The_South_Guard/" );
+ }
+
+ public void testCampaignTutorial( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/tutorial/" );
+ }
+
+ public void testCampaignTB( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Two_Brothers/" );
+ }
+
+ public void testCampaignUtBS( ) throws FileNotFoundException
+ {
+ testPath( dataPath_ + "/campaigns/Under_the_Burning_Suns/" );
+ }
+
+ @Ignore
+ public void testPath( String path )
+ {
+ File theFile = new File( path );
+
+ if ( ! theFile.exists( ) ) {
+ System.out.println( "Skipping non-existent path:" + path );
+ return;
+ }
+
+ if ( theFile.isFile( ) )
+ testFile( path );
+ else {
+ for ( File file : theFile.listFiles( ) ) {
+ testPath( file.getAbsolutePath( ) );
+ }
+ }
+ }
+
+ @Ignore
+ public void testFile( String path )
+ {
+ // just config files
+ if ( ! path.endsWith( ".cfg" ) )
+ return;
+
+ System.out.print( "\nTesting file: " + path + "..." );
+
+ IParseResult res;
+ try {
+ res = getParser( ).parse( new FileReader( path ) );
+ assertEquals( false, res.hasSyntaxErrors( ) );
+ System.out.print( " OK" );
+ }
+ catch ( FileNotFoundException e ) {
+ e.printStackTrace();
+ //should not reach here.
+ assertEquals( true, false );
+ }
+ }
+}
Removed:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokens.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokens.java?rev=50450&view=auto
==============================================================================
---
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokens.java
(original)
+++
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokens.java
(removed)
@@ -1,43 +1,0 @@
-package org.wesnoth.tests.grammar;
-
-import org.wesnoth.tests.WMLTests;
-
-/**
- * Tests parts of the grammar
- */
-public class WMLGrammarTokens extends WMLTests
-{
- // for convenience, define constants for the
- // rule names in your grammar
- // the names of terminal rules will be capitalised
- // and "RULE_" will be appended to the front
- private static final String ID = "RULE_ID";
- private static final String WS = "RULE_WS";
- private static final String SL_COMMENT = "RULE_SL_COMMENT";
-
- public void testID()
- {
- checkTokenisation( "1", ID );
- checkTokenisation( "a", ID );
- checkTokenisation( "abc", ID );
- checkTokenisation( "abc123", ID );
- checkTokenisation( "abc_123", ID );
- }
-
- public void testSLCOMMENT()
- {
- checkTokenisation( "#comment", SL_COMMENT );
- checkTokenisation( "#comment\n", SL_COMMENT );
- checkTokenisation( "# comment \t\t comment\r\n", SL_COMMENT );
- }
-
- public void testTokenSequences()
- {
- checkParsing( "amount=+$random\r\n", grammar.getWMLKeyRule( ) );
-
- checkTokenisation( "123 abc", ID, WS, ID );
- checkTokenisation( "123 \t#comment\n abc", ID, WS, SL_COMMENT, WS, ID
);
- // note that no white space is necessary!
- checkTokenisation( "123abc", ID );
- }
-}
Copied:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokensTests.java
(from r50450,
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokens.java)
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokensTests.java?p2=trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokensTests.java&p1=trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokens.java&r1=50450&r2=50451&rev=50451&view=diff
==============================================================================
---
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokens.java
(original)
+++
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/tests/grammar/WMLGrammarTokensTests.java
Tue Jul 26 17:43:22 2011
@@ -5,7 +5,7 @@
/**
* Tests parts of the grammar
*/
-public class WMLGrammarTokens extends WMLTests
+public class WMLGrammarTokensTests extends WMLTests
{
// for convenience, define constants for the
// rule names in your grammar
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits