<commit_before>package net.mindengine.galen.runner;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.LinkedList;
import java.util.List;

import net.mindengine.galen.javascript.GalenJsExecutor;
import net.mindengine.galen.runner.events.TestEvent;
import net.mindengine.galen.runner.events.TestSuiteEvent;
import net.mindengine.galen.tests.GalenTest;

public class JsTestCollector {

    private List<GalenTest> collectedTests = new LinkedList<GalenTest>();
    private EventHandler eventHandler = new EventHandler();

    public JsTestCollector(List<GalenTest> tests) {
        this.collectedTests = tests;
    }

    public JsTestCollector() {
    }

    public void execute(File file) throws IOException {
        GalenJsExecutor js = new GalenJsExecutor();
        js.putObject("_galenCore", this);
        
        Reader scriptFileReader = new FileReader(file);
        js.eval(scriptFileReader, file.getAbsolutePath());
    }

    public void addTest(GalenTest test) {
        this.collectedTests.add(test);
    }
    
    public List<GalenTest> getCollectedTests() {
        return this.collectedTests;
    }

    public EventHandler getEventHandler() {
        return eventHandler;
    }

    public void setEventHandler(EventHandler eventHandler) {
        this.eventHandler = eventHandler;
    }
    
    
    public void addBeforeTestSuiteEvent(TestSuiteEvent event) {
        eventHandler.getBeforeTestSuiteEvents().add(event);
    }
    
    public void addAfterTestSuiteEvent(TestSuiteEvent event) {
        eventHandler.getAfterTestSuiteEvents().add(event);
    }
    
    public void addBeforeTestEvent(TestEvent event) {
        eventHandler.getBeforeTestEvents().add(event);
    }
    
    public void addAfterTestEvent(TestEvent event) {
        eventHandler.getAfterTestEvents().add(event);
    }

}
<commit_msg>Fixed js test collector so that it shares js executor accross all tests<commit_after>package net.mindengine.galen.runner;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.LinkedList;
import java.util.List;

import net.mindengine.galen.javascript.GalenJsExecutor;
import net.mindengine.galen.runner.events.TestEvent;
import net.mindengine.galen.runner.events.TestSuiteEvent;
import net.mindengine.galen.tests.GalenTest;

public class JsTestCollector {

    private List<GalenTest> collectedTests = new LinkedList<GalenTest>();
    private EventHandler eventHandler = new EventHandler();
    
    private GalenJsExecutor js = createExecutor();
    

    public JsTestCollector(List<GalenTest> tests) {
        this.collectedTests = tests;
    }

    private GalenJsExecutor createExecutor() {
        GalenJsExecutor jsExector = new GalenJsExecutor();
        jsExector.putObject("_galenCore", this);
        return jsExector;
    }

    public JsTestCollector() {
    }

    public void execute(File file) throws IOException {
        
        Reader scriptFileReader = new FileReader(file);
        js.eval(scriptFileReader, file.getAbsolutePath());
    }

    public void addTest(GalenTest test) {
        this.collectedTests.add(test);
    }
    
    public List<GalenTest> getCollectedTests() {
        return this.collectedTests;
    }

    public EventHandler getEventHandler() {
        return eventHandler;
    }

    public void setEventHandler(EventHandler eventHandler) {
        this.eventHandler = eventHandler;
    }
    
    
    public void addBeforeTestSuiteEvent(TestSuiteEvent event) {
        eventHandler.getBeforeTestSuiteEvents().add(event);
    }
    
    public void addAfterTestSuiteEvent(TestSuiteEvent event) {
        eventHandler.getAfterTestSuiteEvents().add(event);
    }
    
    public void addBeforeTestEvent(TestEvent event) {
        eventHandler.getBeforeTestEvents().add(event);
    }
    
    public void addAfterTestEvent(TestEvent event) {
        eventHandler.getAfterTestEvents().add(event);
    }

}

{'fraction_non_alphanumeric': 0.08900523560209424, 'fraction_numerical': 0.0, 'mean_word_length': 3.3799126637554586, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6015878', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1147, 'n_words': 223}