From fa8bd57cbb2decd70647a5b5bc095ba3fdc88ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Thu, 8 Aug 2019 16:33:32 +0200 Subject: [PATCH] Remove Sputnik --- .../org/spockframework/runtime/Sputnik.java | 108 ------------------ .../spockframework/runtime/SputnikSpec.groovy | 45 -------- 2 files changed, 153 deletions(-) delete mode 100755 spock-core/src/main/java/org/spockframework/runtime/Sputnik.java diff --git a/spock-core/src/main/java/org/spockframework/runtime/Sputnik.java b/spock-core/src/main/java/org/spockframework/runtime/Sputnik.java deleted file mode 100755 index e631f54c1d..0000000000 --- a/spock-core/src/main/java/org/spockframework/runtime/Sputnik.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2009 the original author or authors. - * - * 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 org.spockframework.runtime; - -import org.spockframework.runtime.model.*; -import org.spockframework.util.*; - -import org.junit.runner.*; -import org.junit.runner.manipulation.Filter; -import org.junit.runner.manipulation.*; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.model.InitializationError; - -/** - * A JUnit runner for Spock specifications. There is no need to put - * @RunWith(Sputnik) on a specification because the RunWith - * annotation is inherited from class spock.lang.Specification. - * In case you wondered, Sputnik is a combination of the words "Spock" and "JUnit". - * - * @author Peter Niederwieser - */ -// TODO: check if StoppedByUserException thrown in Notifier.fireTestStarted() is handled correctly on our side -public class Sputnik extends Runner implements Filterable, Sortable { - private final Class clazz; - private SpecInfo spec; - private boolean extensionsRun = false; - private boolean descriptionGenerated = false; - - public Sputnik(Class clazz) throws InitializationError { - try { - VersionChecker.checkGroovyVersion("JUnit runner"); - } catch (IncompatibleGroovyVersionException e) { - throw new InitializationError(e); - } - this.clazz = clazz; - } - - @Override - public Description getDescription() { - throw new UnsupportedOperationException("TODO delete Sputnik"); - } - - @Override - public void run(RunNotifier notifier) { - runExtensionsIfNecessary(); - generateSpecDescriptionIfNecessary(); -// RunContext.get().createSpecRunner(getSpec(), notifier).run(); - } - - @Override - public void filter(Filter filter) throws NoTestsRemainException { - invalidateSpecDescription(); -// getSpec().filterFeatures(new JUnitFilterAdapter(filter)); - if (allFeaturesExcluded()) - throw new NoTestsRemainException(); - } - - @Override - public void sort(Sorter sorter) { - invalidateSpecDescription(); -// getSpec().sortFeatures(new JUnitSorterAdapter(sorter)); - } - - private SpecInfo getSpec() { - if (spec == null) { - spec = new SpecInfoBuilder(clazz).build(); - //new JUnitDescriptionGenerator(spec).describeSpecMethods(); - } - return spec; - } - - private void runExtensionsIfNecessary() { - if (extensionsRun) return; - RunContext.get().createExtensionRunner(getSpec()).run(); - extensionsRun = true; - } - - private void generateSpecDescriptionIfNecessary() { - if (descriptionGenerated) return; - //new JUnitDescriptionGenerator(getSpec()).describeSpec(); - descriptionGenerated = true; - } - - private void invalidateSpecDescription() { - descriptionGenerated = false; - } - - private boolean allFeaturesExcluded() { - for (FeatureInfo feature: getSpec().getAllFeatures()) - if (!feature.isExcluded()) return false; - - return true; - } -} diff --git a/spock-specs/src/test/groovy/org/spockframework/runtime/SputnikSpec.groovy b/spock-specs/src/test/groovy/org/spockframework/runtime/SputnikSpec.groovy index 71bbdb47a5..6db2ddf9e5 100644 --- a/spock-specs/src/test/groovy/org/spockframework/runtime/SputnikSpec.groovy +++ b/spock-specs/src/test/groovy/org/spockframework/runtime/SputnikSpec.groovy @@ -13,53 +13,8 @@ */ package org.spockframework.runtime -import org.junit.runner.manipulation.Filter -import org.junit.runner.Description -import org.junit.runner.manipulation.Sorter - import spock.lang.Specification -class SputnikSpec extends Specification { - def "description reflects subsequent filtering"() { - def sputnik = new Sputnik(SputnikSampleSpec) - - expect: - sputnik.description.children.methodName == ["feature1", "feature2", "feature3"] - - when: - sputnik.filter(new Filter() { - @Override - boolean shouldRun(Description description) { - description.methodName == "feature2" - } - @Override - String describe() { - "filter" - } - }) - - then: - sputnik.description.children.methodName == ["feature2"] - } - - def "description reflects subsequent sorting"() { - def sputnik = new Sputnik(SputnikSampleSpec) - - expect: - sputnik.description.children.methodName == ["feature1", "feature2", "feature3"] - - when: - sputnik.sort(new Sorter(new Comparator() { - int compare(Description desc1, Description desc2) { - desc2.methodName <=> desc1.methodName - } - })) - - then: - sputnik.description.children.methodName == ["feature3", "feature2", "feature1"] - } -} - class SputnikSampleSpec extends Specification { def feature1() { expect: true