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 7b8baa6 commit a00571c
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 113 deletions.
Expand Up @@ -29,7 +29,7 @@ import org.junit.Assert.fail
import org.junit.jupiter.api.Test
import org.junit.platform.runner.JUnitPlatform
import org.junit.runner.RunWith
import org.opencypher.tools.tck.api.Scenario
import org.opencypher.tools.tck.api.{CypherTCK, Scenario}

@RunWith(classOf[JUnitPlatform])
abstract class BaseAcceptanceTest extends BaseFeatureTest {
Expand All @@ -42,8 +42,7 @@ abstract class BaseAcceptanceTest extends BaseFeatureTest {
val featuresURI: URI = getClass.getResource("/cypher/features").toURI

val scenarios: Seq[Scenario] = {
val all = 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)
val all = CypherTCK.parseFilesystemFeatures(new File(featuresURI)).flatMap(_.scenarios)
filterScenarios(all, featureToRun, scenarioToRun)
}

Expand Down
Expand Up @@ -27,66 +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," + // Do not test. In 3.4 IS NOT NULL is incorrectly rewritten to Exists. Will be fixed in 3.5.
" exists(n.missing)",
expectedDifferentResults = Configs.Empty)
result.toList should equal(List(Map(
"n.missing IS NULL" -> true,
// "n.missing IS NOT NULL" -> false, // Do not test. In 3.4 IS NOT NULL is incorrectly rewritten to Exists. Will be fixed in 3.5.
"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,6 +1,7 @@
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"
Expand Down
Expand Up @@ -504,6 +504,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 @@ -641,6 +652,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
@@ -1,6 +1,7 @@
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"
Expand Down
Expand Up @@ -13,3 +13,6 @@ 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"

// Formalized and fixed in Neo4j 3.5
Feature "NullOperator": Scenario "Property not null check on null node"
Expand Up @@ -13,3 +13,6 @@ 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"

// Formalized and fixed in Neo4j 3.5
Feature "NullOperator": Scenario "Property not null check on null node"
Expand Up @@ -26,7 +26,7 @@ import org.junit.Assert.fail
import org.junit.jupiter.api.Test
import org.junit.platform.runner.JUnitPlatform
import org.junit.runner.RunWith
import org.opencypher.tools.tck.api.Scenario
import org.opencypher.tools.tck.api.{CypherTCK, Scenario}

@RunWith(classOf[JUnitPlatform])
abstract class BaseTCKTests extends BaseFeatureTest {
Expand All @@ -35,8 +35,7 @@ abstract class BaseTCKTests extends BaseFeatureTest {
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 All @@ -49,5 +48,3 @@ abstract class BaseTCKTests extends BaseFeatureTest {
fail("featureToRun is only for debugging and should not be committed")
}
}


2 changes: 1 addition & 1 deletion enterprise/cypher/pom.xml
Expand Up @@ -20,7 +20,7 @@
<properties>
<licensing.prepend.text>licensing/notice-agpl-prefix.txt</licensing.prepend.text>
<license-text.header>headers/AGPL-3-header.txt</license-text.header>
<opencypher.version>1.0.0-M11</opencypher.version>
<opencypher.version>1.0.0-M12</opencypher.version>
<junit-plattform-runner.version>1.1.0</junit-plattform-runner.version>
<junit-jupiter.version>5.1.0</junit-jupiter.version>
</properties>
Expand Down
Expand Up @@ -22,53 +22,10 @@
*/
package cypher.features

import java.io.File
import java.net.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.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)

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()
}
}
// ---- TCK methods end

def filterScenarios(allScenarios: Seq[Scenario], featureToRun: String, scenarioToRun: String): Seq[Scenario] = {
if (featureToRun.nonEmpty) {
val filteredFeature = allScenarios.filter(s => s.featureName.contains(featureToRun))
Expand Down

0 comments on commit a00571c

Please sign in to comment.