Skip to content

Deduplicate path list before running tests #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Please file your bug reports, enhancement requests, questions and other support

## How to Build

1. [Download](http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html) and install SQL Developer 18.2.0
1. [Download](http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html) and install SQL Developer 18.3.0
2. [Download](https://maven.apache.org/download.cgi) and install Apache Maven 3.5.4
3. [Download](https://git-scm.com/downloads) and install a git command line client
4. Clone the utPLSQL-SQLDeveloper repository
Expand All @@ -57,7 +57,7 @@ Please file your bug reports, enhancement requests, questions and other support

6. Run maven build by the following command

mvn -Dsqldev.basedir=/Applications/SQLDeveloper18.2.0.app/Contents/Resources/sqldeveloper -DskipTests=true clean package
mvn -Dsqldev.basedir=/Applications/SQLDeveloper18.3.0.app/Contents/Resources/sqldeveloper -DskipTests=true clean package

Amend the parameter sqldev.basedir to match the path of your SQL Developer installation. This folder is used to reference Oracle jar files which are not available in public Maven repositories
7. The resulting file ```utplsql_for_SQLDev_x.x.x-SNAPSHOT.zip``` in the ```target``` directory can be installed within SQL Developer
Expand Down
2 changes: 1 addition & 1 deletion sqldev/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<jdk.version.test>1.8</jdk.version.test>
<xtend.version>2.15.0</xtend.version>
<!-- requires SQL Developer 4.1.0 or higher (first version based on JDK 1.8) -->
<sqldev.basedir>/Applications/SQLDeveloper18.2.0.app/Contents/Resources/sqldeveloper</sqldev.basedir>
<sqldev.basedir>/Applications/SQLDeveloper18.3.0.app/Contents/Resources/sqldeveloper</sqldev.basedir>
<final.name>utplsql_for_SQLDev_${project.version}</final.name>
</properties>
<dependencies>
Expand Down
35 changes: 31 additions & 4 deletions sqldev/src/main/java/org/utplsql/sqldev/UtplsqlWorksheet.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
package org.utplsql.sqldev

import java.util.ArrayList
import java.util.HashSet
import java.util.List
import java.util.logging.Logger
import java.util.regex.Pattern
import javax.swing.JSplitPane
import oracle.dbtools.raptor.utils.Connections
import oracle.dbtools.worksheet.editor.OpenWorksheetWizard
Expand Down Expand Up @@ -57,6 +59,30 @@ class UtplsqlWorksheet {
}
}

private def dedupPathList() {
val set = new HashSet<String>
for (path : pathList) {
set.add(path)
}
val ret = new ArrayList<String>
val p = Pattern.compile("((((\\w+)\\.)?\\w+)\\.)?\\w+")
for (path : set) {
val m = p.matcher(path)
if (m.matches()) {
val parent1 = m.group(4) // user
val parent2 = m.group(2) // user.package
if (parent1 === null || !set.contains(parent1)) {
if (parent2 === null || !set.contains(parent2)) {
ret.add(path)
}
}
} else {
logger.severe('''path: «path» did not pattern «p.toString», this is unexected!''')
}
}
return ret
}

private def getCode() '''
«IF preferences.resetPackage»
EXECUTE dbms_session.reset_package;
Expand All @@ -65,10 +91,11 @@ class UtplsqlWorksheet {
«IF preferences.clearScreen»
CLEAR SCREEN
«ENDIF»
«IF pathList.size == 1»
EXECUTE ut.run('«pathList.get(0)»');
«val paths = dedupPathList»
«IF paths.size == 1»
EXECUTE ut.run('«paths.get(0)»');
«ELSE»
EXECUTE ut.run(ut_varchar2_list(«FOR path : pathList SEPARATOR ', '»'«path»'«ENDFOR»));
EXECUTE ut.run(ut_varchar2_list(«FOR path : paths SEPARATOR ', '»'«path»'«ENDFOR»));
«ENDIF»
'''

Expand Down Expand Up @@ -117,7 +144,7 @@ class UtplsqlWorksheet {
thread.start
}

def static void openWithCode(String code, String connectionName) {
static def void openWithCode(String code, String connectionName) {
val worksheet = OpenWorksheetWizard.openNewTempWorksheet(connectionName, code) as Worksheet
if (connectionName === null) {
worksheet.comboConnection = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ class RunGenerator implements OddgenGenerator2 {
return new HashMap<String, Boolean>
}

def private getPath(Node node, Connection conn) {
private def getPath(Node node, Connection conn) {
if (node.id == "SUITE" || node.id == "SUITEPATH") {
return conn.metaData.userName
} else {
return node.id
}
}

def replaceTabsWithSpaces(CharSequence input, int indentSpaces) {
private def replaceTabsWithSpaces(CharSequence input, int indentSpaces) {
val spaces = String.format("%1$"+indentSpaces+"s", "")
return input.toString.replace("\t", spaces)
}
Expand Down
50 changes: 50 additions & 0 deletions sqldev/src/test/java/org/utplsql/sqldev/tests/DalTest.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.utplsql.sqldev.tests

import java.util.ArrayList
import java.util.HashMap
import org.junit.AfterClass
import org.junit.Assert
import org.junit.BeforeClass
Expand Down Expand Up @@ -244,4 +245,53 @@ class DalTest extends AbstractJdbcTest {
Assert.assertEquals("PROCEDURE.JUNIT_P", effective.get(0).id)
}

@Test
def void runnables() {
val dao = new UtplsqlDao(dataSource.connection)
jdbcTemplate.execute('''
CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
-- %suite
-- %suitepath(a.b.c)

-- %test
PROCEDURE t0;

-- %context(mycontext)

-- %test
PROCEDURE t1;

-- %test
PROCEDURE t2;

-- %endcontext

-- %test
PROCEDURE t3;
END junit_utplsql_test_pkg;
''')
val effectiveNodes = dao.runnables()
Assert.assertEquals(16, effectiveNodes.size)
val effective = new HashMap<String, String>
for (node : effectiveNodes) {
effective.put(node.id, node.parentId)
}
Assert.assertEquals(null, effective.get("SUITE"))
Assert.assertEquals("SUITE", effective.get("SCOTT.JUNIT_UTPLSQL_TEST_PKG"))
Assert.assertEquals("SCOTT.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT.JUNIT_UTPLSQL_TEST_PKG.t0"))
Assert.assertEquals("SCOTT.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT.JUNIT_UTPLSQL_TEST_PKG.t1"))
Assert.assertEquals("SCOTT.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT.JUNIT_UTPLSQL_TEST_PKG.t2"))
Assert.assertEquals("SCOTT.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT.JUNIT_UTPLSQL_TEST_PKG.t3"))
Assert.assertEquals(null, effective.get("SUITEPATH"))
Assert.assertEquals("SUITEPATH", effective.get("SCOTT:a"))
Assert.assertEquals("SCOTT:a", effective.get("SCOTT:a.b"))
Assert.assertEquals("SCOTT:a.b", effective.get("SCOTT:a.b.c"))
Assert.assertEquals("SCOTT:a.b.c", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG"))
Assert.assertEquals("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.mycontext"))
Assert.assertEquals("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.t0"))
Assert.assertEquals("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.t3"))
Assert.assertEquals("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.mycontext", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.mycontext.t1"))
Assert.assertEquals("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.mycontext", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.mycontext.t2"))
}

}