<commit_before>package hudson.plugins.scm.koji.client;

import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Result;
import hudson.plugins.scm.koji.FakeKojiXmlRpcApi;
import hudson.plugins.scm.koji.KojiBuildProvider;
import hudson.plugins.scm.koji.KojiSCM;
import hudson.tasks.Shell;
import org.fakekoji.core.FakeKojiTestUtil;
import org.fakekoji.server.JavaServer;
import org.fakekoji.xmlrpc.server.JavaServerConstants;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.jvnet.hudson.test.JenkinsRule;

import java.io.File;
import java.io.FileInputStream;
import java.util.Collections;

import static org.fakekoji.DataGenerator.JDK_8_PACKAGE_NAME;
import static org.fakekoji.DataGenerator.PROJECT_NAME_U;
import static org.fakekoji.DataGenerator.RELEASE_1;
import static org.fakekoji.DataGenerator.SOURCES;
import static org.fakekoji.DataGenerator.SUFFIX;
import static org.fakekoji.DataGenerator.VERSION_1;
import static org.junit.Assert.assertEquals;

public class OToolJenkinsTest {

    @ClassRule
    public static TemporaryFolder temporaryFolder = new TemporaryFolder();

    @Rule
    public JenkinsRule j = new JenkinsRule();

    private static JavaServer javaServer = null;

    @BeforeClass
    public static void setup() throws Exception {
        File tmpDir = temporaryFolder.newFolder();
        javaServer = FakeKojiTestUtil.createDefaultFakeKojiServerWithData(tmpDir);
        javaServer.start();
    }

    @AfterClass
    public static void tearDown() {
        if (javaServer != null) {
            javaServer.stop();
        }
    }

    @Test
    public void testBuildJobFailure() throws Exception {
        /* Test koji scm plugin on existing fake-koji build(s)
           -> should end with success */
        final String expectedFile = JDK_8_PACKAGE_NAME + '-' + VERSION_1 + '-' + RELEASE_1 + '.' + PROJECT_NAME_U + '.' + SOURCES + SUFFIX;
        String shellString = "find . | grep \"" + expectedFile + "\"";
        runTest(
                new FakeKojiXmlRpcApi(
                        PROJECT_NAME_U,
                        "debugMode=release jvm=hotspot buildPlatform=f29.x86_64",
                        "src",
                        false
                ),
                shellString,
                false
        );
    }

    @Test
    public void testBuildJobSuccess() throws Exception {
        final String expectedFile = "java-1.8.0-openjdk-version2-re.l.ease.2.uName.src.tarxz";
        String shellString = "find . | grep \"" + expectedFile + "\"\n";
        runTest(
                new FakeKojiXmlRpcApi(
                        PROJECT_NAME_U,
                        "debugMode=fastdebug jvm=hotspot buildPlatform=f29.x86_64",
                        "src",
                        false
                ),
                shellString,
                true
        );
    }

    @Test
    public void testTestJobFailure() throws Exception {
        final String expectedFile = "java-1.8.0-openjdk-version1-release2.uName.slowdebug.hotspot.f29.x86_64.tarxz";
        String shellString = "find . | grep \"" + expectedFile + "\"\n";
        runTest(
                new FakeKojiXmlRpcApi(
                        PROJECT_NAME_U,
                        "debugMode=slowdebug jvm=hotspot",
                        "f29.x86_64",
                        true
                ),
                shellString,
                false
        );
    }

    @Test
    public void testTestJobSuccess() throws Exception {
        final String expectedFile = "java-1.8.0-openjdk-version1-release1.uName.fastdebug.hotspot.f29.x86_64.tarxz";
        String shellString = "find . | grep \"" + expectedFile + "\"\n";
        runTest(
                new FakeKojiXmlRpcApi(
                        PROJECT_NAME_U,
                        "debugMode=fastdebug jvm=hotspot",
                        "f29.x86_64",
                        true
                ),
                shellString,
                true
        );
    }

    @Test
    public void testTestJobWithSourcesSuccess() throws Exception {
        final String expectedFile = "java-1.8.0-openjdk-version1-re.l.ease.2.uName.fastdebug.hotspot.f29.x86_64.tarxz";
        final String expectedSourceFile = "java-1.8.0-openjdk-version1-re.l.ease.2.uName.src.tarxz";
        String shellString = "find . | grep \"" + expectedFile + "\"\nfind . | grep \"" + expectedSourceFile + "\"\n";
        runTest(
                new FakeKojiXmlRpcApi(
                        PROJECT_NAME_U,
                        "debugMode=fastdebug jvm=hotspot",
                        "f29.x86_64 src",
                        true
                ),
                shellString,
                true
        );
    }<commit_msg>Another attempt to fix test. It looks liek tehy are depndent on day in the week...<commit_after>package hudson.plugins.scm.koji.client;

import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Result;
import hudson.plugins.scm.koji.FakeKojiXmlRpcApi;
import hudson.plugins.scm.koji.KojiBuildProvider;
import hudson.plugins.scm.koji.KojiSCM;
import hudson.tasks.Shell;
import org.fakekoji.core.FakeKojiTestUtil;
import org.fakekoji.server.JavaServer;
import org.fakekoji.xmlrpc.server.JavaServerConstants;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.jvnet.hudson.test.JenkinsRule;

import java.io.File;
import java.io.FileInputStream;
import java.util.Collections;

import static org.fakekoji.DataGenerator.JDK_8_PACKAGE_NAME;
import static org.fakekoji.DataGenerator.PROJECT_NAME_U;
import static org.fakekoji.DataGenerator.RELEASE_1;
import static org.fakekoji.DataGenerator.SOURCES;
import static org.fakekoji.DataGenerator.SUFFIX;
import static org.fakekoji.DataGenerator.VERSION_1;
import static org.junit.Assert.assertEquals;

public class OToolJenkinsTest {

    @ClassRule
    public static TemporaryFolder temporaryFolder = new TemporaryFolder();

    @Rule
    public JenkinsRule j = new JenkinsRule();

    private static JavaServer javaServer = null;

    @BeforeClass
    public static void setup() throws Exception {
        File tmpDir = temporaryFolder.newFolder();
        javaServer = FakeKojiTestUtil.createDefaultFakeKojiServerWithData(tmpDir);
        javaServer.start();
    }

    @AfterClass
    public static void tearDown() {
        if (javaServer != null) {
            javaServer.stop();
        }
    }

    @Test
    public void testBuildJobFailure() throws Exception {
        /* Test koji scm plugin on existing fake-koji build(s)
           -> should end with success */
        final String expectedFile = JDK_8_PACKAGE_NAME + '-' + VERSION_1 + '-' + RELEASE_1 + '.' + PROJECT_NAME_U + '.' + SOURCES + SUFFIX;
        String shellString = "find . | grep \"" + expectedFile + "\"";
        runTest(
                new FakeKojiXmlRpcApi(
                        PROJECT_NAME_U,
                        "debugMode=release jvm=hotspot buildPlatform=f29.x86_64",
                        "src",
                        false
                ),
                shellString,
                false
        );
    }

    @Test
    public void testBuildJobSuccess() throws Exception {
        final String expectedFile = "java-1.8.0-openjdk-version2-release1.uName.src.tarxz";
        String shellString = "find . | grep \"" + expectedFile + "\"\n";
        runTest(
                new FakeKojiXmlRpcApi(
                        PROJECT_NAME_U,
                        "debugMode=fastdebug jvm=hotspot buildPlatform=f29.x86_64",
                        "src",
                        false
                ),
                shellString,
                true
        );
    }

    @Test
    public void testTestJobFailure() throws Exception {
        final String expectedFile = "java-1.8.0-openjdk-version1-release2.uName.slowdebug.hotspot.f29.x86_64.tarxz";
        String shellString = "find . | grep \"" + expectedFile + "\"\n";
        runTest(
                new FakeKojiXmlRpcApi(
                        PROJECT_NAME_U,
                        "debugMode=slowdebug jvm=hotspot",
                        "f29.x86_64",
                        true
                ),
                shellString,
                false
        );
    }

    @Test
    public void testTestJobSuccess() throws Exception {
        final String expectedFile = "java-1.8.0-openjdk-version1-release1.uName.fastdebug.hotspot.f29.x86_64.tarxz";
        String shellString = "find . | grep \"" + expectedFile + "\"\n";
        runTest(
                new FakeKojiXmlRpcApi(
                        PROJECT_NAME_U,
                        "debugMode=fastdebug jvm=hotspot",
                        "f29.x86_64",
                        true
                ),
                shellString,
                true
        );
    }

    @Test
    public void testTestJobWithSourcesSuccess() throws Exception {
        final String expectedFile = "java-1.8.0-openjdk-version1-release1.uName.fastdebug.hotspot.f29.x86_64.tarxz";
        final String expectedSourceFile = "java-1.8.0-openjdk-version1-release1.uName.src.tarxz";
        String shellString = "find . | grep \"" + expectedFile + "\"\nfind . | grep \"" + expectedSourceFile + "\"\n";
        runTest(
                new FakeKojiXmlRpcApi(
                        PROJECT_NAME_U,
                        "debugMode=fastdebug jvm=hotspot",
                        "f29.x86_64 src",
                        true
                ),
                shellString,
                true
        );
    }
{'fraction_non_alphanumeric': 0.09494187232306751, 'fraction_numerical': 0.01611258413216398, 'mean_word_length': 1.892067236803303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3877518', 'n_tokens_mistral': 3033, 'n_tokens_neox': 2808, 'n_words': 539}