<commit_before>package com.github.blindpirate.gogradle

import com.github.blindpirate.gogradle.support.*
import com.github.blindpirate.gogradle.util.ReflectionUtils
import org.junit.runner.notification.RunNotifier
import org.junit.runners.BlockJUnit4ClassRunner
import org.junit.runners.model.FrameworkMethod
import org.junit.runners.model.InitializationError
import org.mockito.MockitoAnnotations

/**
 * Check annotations on a test and do some staff if necessary.
 */
class GogradleRunner extends BlockJUnit4ClassRunner {

    private Map annoToProcessorMap = [
            (AccessWeb)       : AccessWebProcessor,
            (MockOffline)     : MockOfflineProcessor,
            (WithProject)     : WithProjectProcessor,
            (WithResource)    : WithResourceProcessor,
            (WithMockInjector): WithMockInjectorProcessor,
            (OnlyOnUnix)      : OnlyOnUnixProcessor
    ]

    private List<GogradleRunnerProcessor> processors

    Object testInstance

    FrameworkMethod testMethod

    GogradleRunner(Class<?> klass) throws InitializationError {
        super(klass)
    }

    @Override
    Object createTest() throws Exception {
        testInstance = super.createTest()
        MockitoAnnotations.initMocks(testInstance)
        setOfflineIfNecessary()
        processors.each { it.beforeTest(testInstance, testMethod) }
        return testInstance
    }

    def setOfflineIfNecessary() {
        if (ReflectionUtils.getField(GogradleGlobal.INSTANCE, 'offline') == null) {
            ReflectionUtils.setField(GogradleGlobal.INSTANCE, 'offline', false)
        }
    }

    @Override
    protected void runChild(FrameworkMethod method, RunNotifier notifier) {<commit_msg>Support OnlyOnWindows annotation<commit_after>package com.github.blindpirate.gogradle

import com.github.blindpirate.gogradle.support.*
import com.github.blindpirate.gogradle.util.ReflectionUtils
import org.junit.runner.notification.RunNotifier
import org.junit.runners.BlockJUnit4ClassRunner
import org.junit.runners.model.FrameworkMethod
import org.junit.runners.model.InitializationError
import org.mockito.MockitoAnnotations

/**
 * Check annotations on a test and do some staff if necessary.
 */
class GogradleRunner extends BlockJUnit4ClassRunner {

    private Map annoToProcessorMap = [
            (AccessWeb)       : AccessWebProcessor,
            (MockOffline)     : MockOfflineProcessor,
            (WithProject)     : WithProjectProcessor,
            (WithResource)    : WithResourceProcessor,
            (WithMockInjector): WithMockInjectorProcessor,
            (OnlyOnUnix)      : OnlyOnUnixProcessor,
            (OnlyOnWindows)   : OnlyOnWindowsProcessor
    ]

    private List<GogradleRunnerProcessor> processors

    Object testInstance

    FrameworkMethod testMethod

    GogradleRunner(Class<?> klass) throws InitializationError {
        super(klass)
    }

    @Override
    Object createTest() throws Exception {
        testInstance = super.createTest()
        MockitoAnnotations.initMocks(testInstance)
        setOfflineIfNecessary()
        processors.each { it.beforeTest(testInstance, testMethod) }
        return testInstance
    }

    def setOfflineIfNecessary() {
        if (ReflectionUtils.getField(GogradleGlobal.INSTANCE, 'offline') == null) {
            ReflectionUtils.setField(GogradleGlobal.INSTANCE, 'offline', false)
        }
    }

    @Override
    protected void runChild(FrameworkMethod method, RunNotifier notifier) {
{'fraction_non_alphanumeric': 0.07592752372735116, 'fraction_numerical': 0.0011504170261719873, 'mean_word_length': 3.336658354114713, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1116950', 'n_tokens_mistral': 986, 'n_tokens_neox': 958, 'n_words': 180}