Skip to content

Commit

Permalink
Update to TCK M12
Browse files Browse the repository at this point in the history
  • Loading branch information
Lojjs committed Oct 24, 2018
1 parent 176c277 commit b9801c0
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 127 deletions.
Expand Up @@ -6,5 +6,3 @@ Feature "ProcedureCallAcceptance": Scenario "In-query call to procedure with exp
Feature "ProcedureCallAcceptance": Scenario "Standalone call to procedure with argument of type INTEGER accepts value of type FLOAT"
Feature "ProcedureCallAcceptance": Scenario "In-query call to procedure with argument of type INTEGER accepts value of type FLOAT"
Feature "ProcedureCallAcceptance": Scenario "Standalone call to procedure should fail if implicit argument is missing"
//Bug in TCK keys should not mandate order
Feature "KeysAcceptance": Scenario "Using `keys()` on a literal map"
Expand Up @@ -21,16 +21,15 @@ package cypher.features

import org.junit.Assert.fail
import org.junit.jupiter.api.Test
import org.opencypher.tools.tck.api.Scenario
import org.opencypher.tools.tck.api.{CypherTCK, Scenario}

abstract class BaseTCKTests extends BaseFeatureTest {

// these two should be empty on commit!
val featureToRun = ""
val scenarioToRun = ""

val scenarios: Seq[Scenario] = filterScenarios(allTckScenarios, featureToRun, scenarioToRun) //TODO: Change this back to the following line when TCK M12 is released
// filterScenarios(CypherTCK.allTckScenarios, featureToRun, scenarioToRun)
val scenarios: Seq[Scenario] = filterScenarios(CypherTCK.allTckScenarios, featureToRun, scenarioToRun)

@Test
def debugTokensNeedToBeEmpty(): Unit = {
Expand Down
Expand Up @@ -21,65 +21,24 @@ package cypher.features

import java.io.File
import java.net.{URI, URL}
import java.nio.file.{FileSystems, Files, Paths}
import java.util

import org.opencypher.tools.tck.api.CypherTCK.{featureSuffix, featuresPath, parseFeature}
import org.opencypher.tools.tck.api.{Feature, Scenario}

import scala.collection.JavaConverters._
import scala.io.{Codec, Source}
import org.opencypher.tools.tck.api.{CypherTCK, Scenario}

abstract class BaseFeatureTest {

// ---- TCK methods
// TODO: Remove those when M12 is released

def parseFilesystemFeatures(directory: File): Seq[Feature] = {
require(directory.isDirectory)
val featureFileNames = directory.listFiles.filter(_.getName.endsWith(featureSuffix))
featureFileNames.map(parseFilesystemFeature)
}

def parseFilesystemFeature(file: File): Feature = {
parseFeature(file.getAbsolutePath, Source.fromFile(file)(Codec.UTF8).mkString)
}

def parseClasspathFeature(pathUrl: URL): Feature = {
parseFeature(pathUrl.toString, Source.fromURL(pathUrl)(Codec.UTF8).mkString)
}

def allTckScenarios: Seq[Scenario] = parseClasspathFeatures(featuresPath).flatMap(_.scenarios)

// When running externally from e.g. TeamCity we will get a jar and can use the same procedure as for allTckScenarios
// When running locally we need to use the file system instead
def allAcceptanceScenarios: Seq[Scenario] = {
val packageURL: URL = classOf[BaseFeatureTest].getProtectionDomain.getCodeSource.getLocation
val resourcePath: String = "/acceptance/features"

if (packageURL.toString.contains("jar"))
parseClasspathFeatures(resourcePath).flatMap(_.scenarios)
CypherTCK.parseClasspathFeatures(resourcePath).flatMap(_.scenarios)
else {
val featuresURI: URI = new URL(packageURL.toString + resourcePath).toURI
parseFilesystemFeatures(new File(featuresURI)).flatMap(_.scenarios) //TODO: Change this back to the following line when TCK M12 is released
//val all = CypherTCK.parseFilesystemFeatures(new File(featuresURI)).flatMap(_.scenarios)
}
}

def parseClasspathFeatures(path: String): Seq[Feature] = {
val resource = getClass.getResource(path).toURI
val fs = FileSystems.newFileSystem(resource, new util.HashMap[String, String]) // Needed to support `Paths.get` below
try {
val directoryPath = Paths.get(resource)
val paths = Files.newDirectoryStream(directoryPath).asScala.toSeq
val featurePathStrings = paths.map(path => path.toString).filter(_.endsWith(featureSuffix))
val featureUrls = featurePathStrings.map(getClass.getResource(_))
featureUrls.map(parseClasspathFeature)
} finally {
fs.close()
CypherTCK.parseFilesystemFeatures(new File(featuresURI)).flatMap(_.scenarios)
}
}
// ---- TCK methods end

def filterScenarios(allScenarios: Seq[Scenario], featureToRun: String, scenarioToRun: String): Seq[Scenario] = {
if (featureToRun.nonEmpty) {
Expand Down
Expand Up @@ -27,68 +27,6 @@ import org.neo4j.internal.cypher.acceptance.CypherComparisonSupport._

class ExpressionAcceptanceTest extends ExecutionEngineFunSuite with CypherComparisonSupport {

// TODO remove test once TCK dependency is upgraded to 1.0.0-M12
test("property existence checks, on node") {
createNode("exists" -> 1)
val result = executeWith(
expectSucceed = Configs.Interpreted,
query =
"MATCH (n) " +
"RETURN n.missing IS NULL," +
" n.missing IS NOT NULL," +
" exists(n.missing)," +
" n.exists IS NULL," +
" n.exists IS NOT NULL," +
" exists(n.exists)")
result.toList should equal(List(Map(
"n.missing IS NULL" -> true,
"n.missing IS NOT NULL" -> false,
"exists(n.missing)" -> false,
"n.exists IS NULL" -> false,
"n.exists IS NOT NULL" -> true,
"exists(n.exists)" -> true)))
}

// TODO remove test once TCK dependency is upgraded to 1.0.0-M12
test("property existence checks, on optional non-null node") {
createNode("exists" -> 1)
val result = executeWith(
expectSucceed = Configs.Interpreted,
query =
"OPTIONAL MATCH (n) " +
"RETURN n.missing IS NULL," +
" n.missing IS NOT NULL," +
" exists(n.missing)," +
" n.exists IS NULL," +
" n.exists IS NOT NULL," +
" exists(n.exists)")
result.toList should equal(List(Map(
"n.missing IS NULL" -> true,
"n.missing IS NOT NULL" -> false,
"exists(n.missing)" -> false,
"n.exists IS NULL" -> false,
"n.exists IS NOT NULL" -> true,
"exists(n.exists)" -> true)))
}

// TODO remove test once TCK dependency is upgraded to 1.0.0-M12
test("property existence checks, on optional null node") {
val result = executeWith(
expectSucceed = Configs.Interpreted,
query =
"OPTIONAL MATCH (n) " +
"RETURN n.missing IS NULL," +
" n.missing IS NOT NULL," +
" exists(n.missing)",
expectedDifferentResults =
TestConfiguration(Versions.V2_3 -> Versions.V3_4, Planners.all, Runtimes.all) +
TestConfiguration(Versions.Default, Planners.Rule, Runtimes.all))
result.toList should equal(List(Map(
"n.missing IS NULL" -> true,
"n.missing IS NOT NULL" -> false,
"exists(n.missing)" -> null)))
}

test("should handle map projection with property selectors") {
createNode("foo" -> 1, "bar" -> "apa")

Expand Down
Expand Up @@ -161,6 +161,8 @@ Feature "ListOperations": Scenario "Use list lookup based on parameters when the
Feature "ListOperations": Scenario "Use list lookup based on parameters when there is rhs type information"
Feature "ListOperations": Scenario "Fail at runtime when attempting to index with a String into a List"
Feature "ListOperations": Scenario "Fail at runtime when trying to index into a list with a list"
Feature "ListOperations": Scenario "List slice with parameterised range"
Feature "ListOperations": Scenario "List slice with parameterised invalid range"
Feature "DeleteAcceptance": Scenario "Delete node from a list"
Feature "DeleteAcceptance": Scenario "Delete relationship from a list"
Feature "FunctionsAcceptance": Scenario "`properties()` on a node"
Expand Down Expand Up @@ -245,3 +247,4 @@ Feature "TemporalParseAcceptance": Scenario "Should parse local date time from s
Feature "TemporalParseAcceptance": Scenario "Should parse date time from string"
Feature "TemporalParseAcceptance": Scenario "Should parse date time with named time zone from string"
Feature "TemporalParseAcceptance": Scenario "Should parse duration from string"
Feature "NullOperator": Scenario "Property not null check on null node"
Expand Up @@ -50,3 +50,4 @@ Feature "ProcedureCallAcceptance": Scenario "In-query call to procedure that tak
Feature "ProcedureCallAcceptance": Scenario "In-query call to procedure with explicit arguments that drops all result fields"
Feature "ProcedureCallAcceptance": Scenario "Standalone call to procedure with argument of type INTEGER accepts value of type FLOAT"
Feature "ProcedureCallAcceptance": Scenario "In-query call to procedure with argument of type INTEGER accepts value of type FLOAT"
Feature "NullOperator": Scenario "Property not null check on null node"
@@ -1,11 +1,9 @@
Feature "MiscellaneousErrorAcceptance": Scenario "Failing on merging relationship with null property"
Feature "MiscellaneousErrorAcceptance": Scenario "Failing on merging node with null property"
Feature "MiscellaneousErrorAcceptance": Scenario "Failing when setting a list of maps as a property"
Feature "NullOperator": Scenario "Property not null check on null node"
Feature "ProcedureCallAcceptance": Scenario "In-query call to procedure that takes no arguments and yields no results"
Feature "ProcedureCallAcceptance": Scenario "In-query call to procedure with explicit arguments that drops all result fields"
Feature "ProcedureCallAcceptance": Scenario "Standalone call to procedure with argument of type INTEGER accepts value of type FLOAT"
Feature "ProcedureCallAcceptance": Scenario "In-query call to procedure with argument of type INTEGER accepts value of type FLOAT"
Feature "ProcedureCallAcceptance": Scenario "Standalone call to procedure should fail if implicit argument is missing"

//Bug in TCK keys should not mandate order
Feature "KeysAcceptance": Scenario "Using `keys()` on a literal map"
Expand Up @@ -503,6 +503,17 @@ Feature "ListOperations": Scenario "Use list lookup based on parameters when the
Feature "ListOperations": Scenario "Use list lookup based on parameters when there is rhs type information"
Feature "ListOperations": Scenario "Fail at runtime when attempting to index with a String into a List"
Feature "ListOperations": Scenario "Fail at runtime when trying to index into a list with a list"
Feature "ListOperations": Scenario "List slice"
Feature "ListOperations": Scenario "List slice with implicit end"
Feature "ListOperations": Scenario "List slice with implicit start"
Feature "ListOperations": Scenario "List slice with singleton range"
Feature "ListOperations": Scenario "List slice with empty range"
Feature "ListOperations": Scenario "List slice with negative range"
Feature "ListOperations": Scenario "List slice with invalid range"
Feature "ListOperations": Scenario "List slice with exceeding range"
Feature "ListOperations": Scenario "List slice with null range"
Feature "ListOperations": Scenario "List slice with parameterised range"
Feature "ListOperations": Scenario "List slice with parameterised invalid range"
Feature "ListComprehension": Scenario "Returning a list comprehension"
Feature "ListComprehension": Scenario "Using a list comprehension in a WITH"
Feature "ListComprehension": Scenario "Using a list comprehension in a WHERE"
Expand Down Expand Up @@ -640,6 +651,15 @@ Feature "NullAcceptance": Scenario "Ignore null when setting label"
Feature "NullAcceptance": Scenario "Ignore null when removing label"
Feature "NullAcceptance": Scenario "Ignore null when deleting node"
Feature "NullAcceptance": Scenario "Ignore null when deleting relationship"
Feature "NullAcceptance": Scenario "Property existence check on non-null node"
Feature "NullAcceptance": Scenario "Property existence check on optional non-null node"
Feature "NullAcceptance": Scenario "Property existence check on null node"
Feature "NullOperator": Scenario "Property null check on non-null node"
Feature "NullOperator": Scenario "Property not null check on non-null node"
Feature "NullOperator": Scenario "Property null check on optional non-null node"
Feature "NullOperator": Scenario "Property not null check on optional non-null node"
Feature "NullOperator": Scenario "Property null check on null node"
Feature "NullOperator": Scenario "Property not null check on null node"
Feature "Aggregation": Scenario "`max()` over strings"
Feature "Aggregation": Scenario "`min()` over strings"
Feature "Aggregation": Scenario "`max()` over integers"
Expand Down
Expand Up @@ -445,6 +445,12 @@ Feature "NullAcceptance": Scenario "Ignore null when setting label"
Feature "NullAcceptance": Scenario "Ignore null when removing label"
Feature "NullAcceptance": Scenario "Ignore null when deleting node"
Feature "NullAcceptance": Scenario "Ignore null when deleting relationship"
Feature "NullAcceptance": Scenario "Property existence check on optional non-null node"
Feature "NullAcceptance": Scenario "Property existence check on null node"
Feature "NullOperator": Scenario "Property null check on optional non-null node"
Feature "NullOperator": Scenario "Property not null check on optional non-null node"
Feature "NullOperator": Scenario "Property null check on null node"
Feature "NullOperator": Scenario "Property not null check on null node"
Feature "SkipLimitAcceptanceTest": Scenario "SKIP with an expression that does not depend on variables"
Feature "SkipLimitAcceptanceTest": Scenario "LIMIT with an expression that does not depend on variables"
Feature "ProcedureCallAcceptance": Scenario "In-query call to procedure that takes no arguments"
Expand All @@ -461,6 +467,3 @@ Feature "ProcedureCallAcceptance": Scenario "Standalone call to procedure with a
Feature "ProcedureCallAcceptance": Scenario "In-query call to procedure with argument of type INTEGER accepts value of type FLOAT"
Feature "ProcedureCallAcceptance": Scenario "In-query call to procedure with null argument"
Feature "ProcedureCallAcceptance": Scenario "Standalone call to procedure should fail if implicit argument is missing"

//Bug in TCK keys should not mandate order
Feature "KeysAcceptance": Scenario "Using `keys()` on a literal map"
Expand Up @@ -13,6 +13,3 @@ Feature "MiscellaneousErrorAcceptance": Scenario "Failing when setting a list of

// To classify
Feature "ProcedureCallAcceptance": Scenario "Standalone call to procedure should fail if implicit argument is missing"

//Bug in TCK keys should not mandate order
Feature "KeysAcceptance": Scenario "Using `keys()` on a literal map"
Expand Up @@ -13,6 +13,3 @@ Feature "MiscellaneousErrorAcceptance": Scenario "Failing when setting a list of

// Different error type in Neo4j
Feature "ProcedureCallAcceptance": Scenario "Standalone call to procedure should fail if implicit argument is missing"

//Bug in TCK keys should not mandate order
Feature "KeysAcceptance": Scenario "Using `keys()` on a literal map"
Expand Up @@ -24,16 +24,15 @@ package cypher.features

import org.junit.Assert.fail
import org.junit.jupiter.api.Test
import org.opencypher.tools.tck.api.Scenario
import org.opencypher.tools.tck.api.{CypherTCK, Scenario}

abstract class EnterpriseBaseTCKTests extends BaseFeatureTest {

// these two should be empty on commit!
val featureToRun = ""
val scenarioToRun = ""

val scenarios: Seq[Scenario] = filterScenarios(allTckScenarios, featureToRun, scenarioToRun) //TODO: Change this back to the following line when TCK M12 is released
// filterScenarios(CypherTCK.allTckScenarios, featureToRun, scenarioToRun)
val scenarios: Seq[Scenario] = filterScenarios(CypherTCK.allTckScenarios, featureToRun, scenarioToRun)

@Test
def debugTokensNeedToBeEmpty(): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -102,7 +102,7 @@
<cypher.compatibility.23>2.3.12</cypher.compatibility.23>
<cypher.compatibility.31>3.1.9</cypher.compatibility.31>
<cypher.compatibility.34>3.4.9</cypher.compatibility.34>
<opencypher.version>1.0.0-M11</opencypher.version>
<opencypher.version>1.0.0-M12</opencypher.version>
<caffeine.version>2.6.2</caffeine.version>
<required.maven.version>3.5.2</required.maven.version>
<jackson.version>1.9.13</jackson.version>
Expand Down

0 comments on commit b9801c0

Please sign in to comment.