Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Fred Eisele
fql
Commits
27131db7
Commit
27131db7
authored
Sep 14, 2018
by
Fred Eisele
Browse files
gradle runs tests
parent
9f8ff47c
Changes
15
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
27131db7
...
...
@@ -8,6 +8,7 @@ import org.babeloff.plugins.antlr.Antlr4Task
apply
plugin:
'java'
apply
plugin:
'maven'
apply
plugin:
'application'
apply
plugin:
'idea'
apply
plugin:
'eclipse'
...
...
@@ -16,6 +17,8 @@ group = 'net.catdata'
project
.
ext
.
versionFile
=
file
(
'gradle/version.properties'
)
mainClassName
=
"catdata.ide.IDE"
task
loadVersion
{
project
.
version
=
ProjectVersion
.
read
(
logger
,
versionFile
)
}
...
...
@@ -81,7 +84,7 @@ task antlrGen (type: Antlr4Task) {
lexerGrammar
=
file
(
"${project.rootDir}/src/main/antlr/catdata/aql/grammar/AqlLexerRules.g4"
)
parserGrammar
=
file
(
"${project.rootDir}/src/main/antlr/catdata/aql/grammar/AqlParser.g4"
)
module
=
"catdata.aql.grammar"
targetDir
=
file
(
"${project.buildDir}/generated-src/
antlr/main
/catdata/aql/grammar"
)
targetDir
=
file
(
"${project.buildDir}/generated-src/
java
/catdata/aql/grammar"
)
visitor
=
false
listener
=
true
}
...
...
@@ -89,7 +92,7 @@ task antlrGen (type: Antlr4Task) {
compileJava
.
dependsOn
antlrGen
wrapper
{
gradleVersion
=
'4.10'
gradleVersion
=
'4.10
.1
'
distributionUrl
=
"https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
...
...
@@ -97,28 +100,34 @@ wrapper {
sourceSets
{
main
{
java
{
srcDirs
=
[
'src/main/java'
,
'build/generated-src/antlr'
]
srcDirs
=
[
'src/main/java'
,
'build/generated-src/java'
]
}
resources
{
srcDirs
=
[
"${project.projectDir}/resources"
]
}
}
test
{
java
{
srcDirs
=
[
'test/java'
]
srcDirs
=
[
"${project.projectDir}/src/test/java"
]
}
resources
{
srcDirs
=
[
"${project.projectDir}/resources"
]
}
}
}
idea
{
module
{
generatedSourceDirs
+=
file
(
"${project.buildDir}/generated-src/
antlr/main
"
)
generatedSourceDirs
+=
file
(
"${project.buildDir}/generated-src/
java
"
)
downloadJavadoc
=
true
downloadSources
=
false
}
}
repositories
{
maven
{
url
"https://nexus.isis.vanderbilt.edu/repository/maven-releases"
}
maven
{
url
"https://nexus.isis.vanderbilt.edu/repository/maven-
snapshot
s"
}
maven
Central
()
maven
Central
()
maven
{
url
"https://nexus.isis.vanderbilt.edu/repository/maven-
release
s"
}
maven
{
url
"https://nexus.isis.vanderbilt.edu/repository/maven-snapshots"
}
}
dependencies
{
...
...
@@ -146,7 +155,8 @@ dependencies {
'junit:junit:4.12'
)
testImplementation
(
'org.junit.jupiter:junit-jupiter-api:5.3.1'
'org.junit.jupiter:junit-jupiter-api:5.3.1'
,
'org.junit.jupiter:junit-jupiter-params:5.3.1'
)
testRuntimeOnly
(
'org.junit.jupiter:junit-jupiter-engine:5.3.1'
,
...
...
buildSrc/src/main/groovy/org/babeloff/ProjectVersion.groovy
View file @
27131db7
...
...
@@ -30,10 +30,13 @@ class ProjectVersion {
}
Properties
versionProps
=
new
Properties
()
versionFile
.
withInputStream
{
stream
->
versionProps
.
load
(
stream
)
}
new
ProjectVersion
(
versionProps
.
year
.
toInteger
(),
ProjectVersion
pv
=
new
ProjectVersion
(
versionProps
.
year
.
toInteger
(),
versionProps
.
month
.
toInteger
(),
versionProps
.
day
.
toInteger
(),
versionProps
.
release
.
toBoolean
())
logger
.
quiet
'the version specified is: '
+
pv
.
toString
()
return
pv
;
}
@Override
...
...
gradle/wrapper/gradle-wrapper.properties
View file @
27131db7
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-4.10-all.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-4.10
.1
-all.zip
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
resources/examples/aql/All_Syntax.aql
→
resources/examples/aql
_extra
/All_Syntax.aql
View file @
27131db7
File moved
resources/examples/aql/Delta.aql
→
resources/examples/aql
_extra
/Delta.aql
View file @
27131db7
File moved
resources/examples/aql/FinanceColim2.aql
→
resources/examples/aql
_extra
/FinanceColim2.aql
View file @
27131db7
File moved
resources/examples/aql/Foreign Keys.aql
→
resources/examples/aql
_extra
/Foreign Keys.aql
View file @
27131db7
File moved
resources/examples/aql/Inverse.aql
→
resources/examples/aql
_extra
/Inverse.aql
View file @
27131db7
File moved
resources/examples/aql/Joinless.aql
→
resources/examples/aql
_extra
/Joinless.aql
View file @
27131db7
File moved
resources/examples/aql/PharmaColim2.aql
→
resources/examples/aql
_extra
/PharmaColim2.aql
View file @
27131db7
File moved
resources/examples/aql/Pullback.aql
→
resources/examples/aql
_extra
/Pullback.aql
View file @
27131db7
File moved
resources/examples/aql/Pushout.aql
→
resources/examples/aql
_extra
/Pushout.aql
View file @
27131db7
File moved
src/main/java/catdata/ide/Examples.java
View file @
27131db7
...
...
@@ -84,7 +84,9 @@ public class Examples {
if
(
url
==
null
)
{
URL
l
=
ClassLoader
.
getSystemResource
(
"examples"
);
if
(
l
==
null
)
{
new
RuntimeException
(
"Cannot locate examples"
).
printStackTrace
();
final
String
classpath
=
System
.
getProperty
(
"java.class.path"
);
final
String
[]
classpathEntries
=
classpath
.
split
(
File
.
pathSeparator
);
new
RuntimeException
(
"Cannot locate 'examples' from : "
+
classpath
).
printStackTrace
();
HashMap
<
Language
,
List
<
Example
>>
ret
=
new
HashMap
<>();
for
(
Language
ll
:
Language
.
values
())
{
ret
.
put
(
ll
,
new
LinkedList
<>());
...
...
src/test/java/catdata/aql/AqlExampleTest.java
0 → 100644
View file @
27131db7
package
catdata.aql
;
import
catdata.Program
;
import
catdata.aql.exp.AqlEnv
;
import
catdata.aql.exp.AqlMultiDriver
;
import
catdata.aql.exp.AqlParserFactory
;
import
catdata.aql.exp.Exp
;
import
catdata.ide.Examples
;
import
catdata.ide.Language
;
import
org.junit.jupiter.params.ParameterizedTest
;
import
org.junit.jupiter.params.provider.Arguments
;
import
org.junit.jupiter.params.provider.MethodSource
;
import
java.util.stream.Stream
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
fail
;
public
class
AqlExampleTest
{
@ParameterizedTest
@MethodSource
(
"loadExamples"
)
public
void
testSourceText
(
String
description
,
String
src
)
{
System
.
out
.
println
(
"testing example: "
+
description
);
try
{
final
Program
<
Exp
<?>>
prog
=
AqlParserFactory
.
getParser
().
parseProgram
(
src
);
final
AqlMultiDriver
driver
=
new
AqlMultiDriver
(
prog
,
new
String
[
1
],
null
);
driver
.
start
();
final
AqlEnv
lastEnv
=
driver
.
env
;
if
(
lastEnv
.
exn
!=
null
)
{
throw
lastEnv
.
exn
;
}
}
catch
(
Exception
e
)
{
final
String
msg
=
new
StringBuilder
()
.
append
(
"Test failed for test case '"
)
.
append
(
description
)
.
append
(
"' \n"
)
.
append
(
src
)
.
append
(
"'.\n"
)
.
append
(
e
.
getStackTrace
())
.
toString
();
// System.out.println( msg );
fail
(
msg
);
}
}
public
static
Stream
<
Arguments
>
loadExamples
()
{
return
Examples
.
getExamples
(
Language
.
AQL
).
stream
()
.
map
(
example
->
Arguments
.
of
(
example
.
getName
(),
example
.
getText
()));
}
}
src/test/java/catdata/aql/AqlTest.java
View file @
27131db7
...
...
@@ -2,7 +2,7 @@ package catdata.aql;
import
catdata.Program
;
import
catdata.Util
;
import
catdata.aql.exp.AqlParser
;
import
catdata.aql.exp.AqlParser
Factory
;
import
catdata.aql.exp.AqlEnv
;
import
catdata.aql.exp.AqlMultiDriver
;
import
catdata.aql.exp.Exp
;
...
...
@@ -20,52 +20,5 @@ import org.junit.jupiter.api.Test;
public
class
AqlTest
{
// This duplicated some of AqlTester, but as headless unit tests.
@Test
public
void
testAqlExamples
()
{
for
(
Example
e
:
Examples
.
getExamples
(
Language
.
AQL
))
{
System
.
out
.
println
(
"testing example: "
+
e
.
getName
());
testSourceText
(
"example: "
+
e
.
getName
(),
e
.
getText
());
}
}
/////////////////////////////////////////////////////////////////////////////////
//
// helpers
//
/////////////////////////////////////////////////////////////////////////////////
public
void
testSourceText
(
String
description
,
String
src
)
{
try
{
Program
<
Exp
<?>>
prog
=
AqlParser
.
getParser
().
parseProgram
(
src
);
testAqlMultiDriver
(
prog
);
}
catch
(
Exception
e
)
{
fail
(
"Test failed for test case '"
+
description
+
"'."
);
// e.printStackTrace();
System
.
out
.
println
(
"Test failed for test case '"
+
description
+
"'.\n"
+
e
.
getStackTrace
());
fail
(
"Test failed for test case '"
+
description
+
"'.\n"
+
e
.
getStackTrace
());
}
}
// TODO Code is similar to that in AqlTester and AqlCmdLine; refactor.
public
Program
<
Exp
<?>>
parseFileOrNull
(
String
fileName
)
{
try
(
FileReader
r
=
new
FileReader
(
fileName
))
{
String
src
=
Util
.
readFile
(
r
);
Program
<
Exp
<?>>
prog
=
AqlParser
.
getParser
().
parseProgram
(
src
);
return
prog
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
// TODO Code is similar to that in AqlTester and AqlCmdLine; refactor.
public
void
testAqlMultiDriver
(
Program
<
Exp
<?>>
prog
)
{
AqlMultiDriver
driver
=
new
AqlMultiDriver
(
prog
,
new
String
[
1
],
null
);
driver
.
start
();
AqlEnv
lastEnv
=
driver
.
env
;
if
(
lastEnv
.
exn
!=
null
)
{
throw
lastEnv
.
exn
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment