From e16deafc899dbbaaf06bbbe10f831355aa507456 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 13 Jun 2017 15:34:35 +0200 Subject: [PATCH] make slowCheck available on TC, but don't run apply-and-revert tests yet --- community-main.iml | 1 + java/java-tests/java-tests.iml | 1 + .../AbstractApplyAndRevertTestCase.java | 27 ++++++++++++++++++- .../java/propertyBased}/ActionOnRange.java | 17 +++++++++++- .../ApplyRandomIntentionsTest.java | 20 +++++++++++++- .../CompletionConsistencyTest.java | 21 ++++++++++++++- slowCheck/slowCheck.iml | 5 +--- slowCheck/src/slowCheck/DataStructure.java | 2 +- slowCheck/test/slowCheck/GeneratorTest.java | 15 +++++------ 9 files changed, 92 insertions(+), 17 deletions(-) rename {slowCheck/test/slowCheck => java/java-tests/testSrc/com/intellij/java/propertyBased}/AbstractApplyAndRevertTestCase.java (88%) rename {slowCheck/test/slowCheck => java/java-tests/testSrc/com/intellij/java/propertyBased}/ActionOnRange.java (54%) rename {slowCheck/test/slowCheck => java/java-tests/testSrc/com/intellij/java/propertyBased}/ApplyRandomIntentionsTest.java (92%) rename {slowCheck/test/slowCheck => java/java-tests/testSrc/com/intellij/java/propertyBased}/CompletionConsistencyTest.java (87%) diff --git a/community-main.iml b/community-main.iml index 8f78b6079171..d707808b289d 100644 --- a/community-main.iml +++ b/community-main.iml @@ -125,5 +125,6 @@ + \ No newline at end of file diff --git a/java/java-tests/java-tests.iml b/java/java-tests/java-tests.iml index 3ce666ee24bd..38e243dccd6b 100644 --- a/java/java-tests/java-tests.iml +++ b/java/java-tests/java-tests.iml @@ -56,5 +56,6 @@ + \ No newline at end of file diff --git a/slowCheck/test/slowCheck/AbstractApplyAndRevertTestCase.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/AbstractApplyAndRevertTestCase.java similarity index 88% rename from slowCheck/test/slowCheck/AbstractApplyAndRevertTestCase.java rename to java/java-tests/testSrc/com/intellij/java/propertyBased/AbstractApplyAndRevertTestCase.java index c94d5facd49a..03015538dfd3 100644 --- a/slowCheck/test/slowCheck/AbstractApplyAndRevertTestCase.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/AbstractApplyAndRevertTestCase.java @@ -1,4 +1,19 @@ -package slowCheck; +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.java.propertyBased; import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.ide.impl.ProjectUtil; @@ -32,9 +47,11 @@ import com.intellij.psi.stubs.StubTree; import com.intellij.testFramework.CompilerTester; import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.TestDataProvider; +import com.intellij.testFramework.UsefulTestCase; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import slowCheck.Generator; import java.io.File; import java.util.ArrayList; @@ -72,6 +89,14 @@ public abstract class AbstractApplyAndRevertTestCase extends PlatformTestCase { } + @Override + protected boolean shouldRunTest() { + if (UsefulTestCase.IS_UNDER_TEAMCITY) { + return false; + } + return super.shouldRunTest(); + } + protected abstract String getTestDataPath(); public void setUp() throws Exception { diff --git a/slowCheck/test/slowCheck/ActionOnRange.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/ActionOnRange.java similarity index 54% rename from slowCheck/test/slowCheck/ActionOnRange.java rename to java/java-tests/testSrc/com/intellij/java/propertyBased/ActionOnRange.java index d77a894fd072..5b8138d3e912 100644 --- a/slowCheck/test/slowCheck/ActionOnRange.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/ActionOnRange.java @@ -1,4 +1,19 @@ -package slowCheck; +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.java.propertyBased; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.RangeMarker; diff --git a/slowCheck/test/slowCheck/ApplyRandomIntentionsTest.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/ApplyRandomIntentionsTest.java similarity index 92% rename from slowCheck/test/slowCheck/ApplyRandomIntentionsTest.java rename to java/java-tests/testSrc/com/intellij/java/propertyBased/ApplyRandomIntentionsTest.java index 0c492d31c24c..0b84fa4dc325 100644 --- a/slowCheck/test/slowCheck/ApplyRandomIntentionsTest.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/ApplyRandomIntentionsTest.java @@ -1,4 +1,19 @@ -package slowCheck; +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.java.propertyBased; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.openapi.command.WriteCommandAction; @@ -13,6 +28,9 @@ import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl; import com.intellij.util.SystemProperties; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.Nullable; +import slowCheck.Checker; +import slowCheck.CheckerSettings; +import slowCheck.Generator; import java.util.List; import java.util.Objects; diff --git a/slowCheck/test/slowCheck/CompletionConsistencyTest.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/CompletionConsistencyTest.java similarity index 87% rename from slowCheck/test/slowCheck/CompletionConsistencyTest.java rename to java/java-tests/testSrc/com/intellij/java/propertyBased/CompletionConsistencyTest.java index 9e0f9ca9b678..7d575b531d88 100644 --- a/slowCheck/test/slowCheck/CompletionConsistencyTest.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/CompletionConsistencyTest.java @@ -1,4 +1,19 @@ -package slowCheck; +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.java.propertyBased; import com.intellij.codeInsight.completion.CodeCompletionHandlerBase; import com.intellij.codeInsight.completion.CompletionType; @@ -17,6 +32,10 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.SystemProperties; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; +import slowCheck.Checker; +import slowCheck.CheckerSettings; +import slowCheck.Generator; +import slowCheck.IntDistribution; import java.util.List; diff --git a/slowCheck/slowCheck.iml b/slowCheck/slowCheck.iml index 6a3c0365cfd9..ec7729dfb780 100644 --- a/slowCheck/slowCheck.iml +++ b/slowCheck/slowCheck.iml @@ -9,10 +9,7 @@ - - - - + \ No newline at end of file diff --git a/slowCheck/src/slowCheck/DataStructure.java b/slowCheck/src/slowCheck/DataStructure.java index f6e309292133..8ddce83042bf 100644 --- a/slowCheck/src/slowCheck/DataStructure.java +++ b/slowCheck/src/slowCheck/DataStructure.java @@ -7,7 +7,7 @@ import java.util.function.Predicate; /** * @author peter */ -interface DataStructure { +public interface DataStructure { default int drawInt() { return drawInt(BoundedIntDistribution.ALL_INTS); diff --git a/slowCheck/test/slowCheck/GeneratorTest.java b/slowCheck/test/slowCheck/GeneratorTest.java index 38728daeddf9..8cb019611a82 100644 --- a/slowCheck/test/slowCheck/GeneratorTest.java +++ b/slowCheck/test/slowCheck/GeneratorTest.java @@ -1,6 +1,5 @@ package slowCheck; -import com.intellij.util.containers.ContainerUtil; import junit.framework.TestCase; import java.util.List; @@ -8,8 +7,6 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import static slowCheck.Generator.*; -import static slowCheck.Generator.doubles; -import static slowCheck.Generator.listOf; /** * @author peter @@ -54,12 +51,14 @@ public class GeneratorTest extends TestCase { } public void testSuccess() { - Checker.forAll(ourTestSettings, listOf(integers(-1, 1)), l -> - l.stream().allMatch(i -> Math.abs(i) <= 1)); + Checker.forAll(listOf(integers(-1, 1)), + l -> l.stream().allMatch(i -> Math.abs(i) <= 1)); } public void testSortedDoublesNonDescending() { - checkFalsified(listOf(doubles()), l -> isSorted(ContainerUtil.sorted(l)), 329); + checkFalsified(listOf(doubles()), + l -> isSorted(l.stream().sorted().collect(Collectors.toList())), + 329); } private static boolean isSorted(List list) { @@ -78,12 +77,12 @@ public class GeneratorTest extends TestCase { } public void testSuchThat() { - Checker.forAll(ourTestSettings, integers(-1, 1).suchThat(i -> i == 0), i -> i == 0); + Checker.forAll(integers(-1, 1).suchThat(i -> i == 0), i -> i == 0); } public void testUnsatisfiableSuchThat() { try { - Checker.forAll(ourTestSettings, integers(-1, 1).suchThat(i -> i >2), i -> i == 0); + Checker.forAll(integers(-1, 1).suchThat(i -> i >2), i -> i == 0); fail(); } catch (CannotSatisfyCondition ignored) {