<commit_before>/*******************************************************************************
 * Copyright (c) 2005, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 
 *******************************************************************************/
package ch.hsr.ifs.pystructure.tests.typeinference;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.LinkedList;

import junit.framework.TestCase;
import junit.framework.TestResult;
import junit.framework.TestSuite;
import ch.hsr.ifs.pystructure.playground.Structure101Logger;
import ch.hsr.ifs.pystructure.typeinference.inferencer.PythonTypeInferencer;
import ch.hsr.ifs.pystructure.typeinference.inferencer.logger.CombinedLogger;
import ch.hsr.ifs.pystructure.typeinference.inferencer.logger.IGoalEngineLogger;
import ch.hsr.ifs.pystructure.typeinference.visitors.Workspace;

public class TypeInferenceSuite extends TestSuite {
	
	private PythonTypeInferencer inferencer;

	public TypeInferenceSuite(String testsDirectory) {
		super(testsDirectory);
		File dir = new File(testsDirectory);
		
		File[] files = dir.listFiles(new FilenameFilter() {
			public boolean accept(File file, String name) {
				return name.matches(".+\\.py$");
			}
		});
		
		
		Structure101Logger s101log = new Structure101Logger();
		IGoalEngineLogger logger = new CombinedLogger(s101log);
		inferencer = new PythonTypeInferencer(logger);
		
		LinkedList<String> sysPath = new LinkedList<String>();
		Workspace workspace = new Workspace(testsDirectory, sysPath);
		
		for (File file : files) {
			try {
				TestCase test = new TypeInferenceTest(file.getName(), file, workspace, inferencer, s101log);
				addTest(test);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
	}
	
	public void run(TestResult result) {
		super.run(result);
		inferencer.shutdown();<commit_msg>The TypeinferencerSuite now also runs autonomously <commit_after>/*******************************************************************************
 * Copyright (c) 2005, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 
 *******************************************************************************/
package ch.hsr.ifs.pystructure.tests.typeinference;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.LinkedList;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestResult;
import junit.framework.TestSuite;
import ch.hsr.ifs.pystructure.playground.Structure101Logger;
import ch.hsr.ifs.pystructure.typeinference.inferencer.PythonTypeInferencer;
import ch.hsr.ifs.pystructure.typeinference.inferencer.logger.CombinedLogger;
import ch.hsr.ifs.pystructure.typeinference.inferencer.logger.IGoalEngineLogger;
import ch.hsr.ifs.pystructure.typeinference.inferencer.logger.StatsLogger;
import ch.hsr.ifs.pystructure.typeinference.visitors.Workspace;

public class TypeInferenceSuite extends TestSuite {
	
	private PythonTypeInferencer inferencer;

	public static Test suite() {
		return new TypeInferenceSuite("tests/python/typeinference/");
	}
	
	public TypeInferenceSuite(String testsDirectory) {
		super(testsDirectory);
		File dir = new File(testsDirectory);
		
		File[] files = dir.listFiles(new FilenameFilter() {
			public boolean accept(File file, String name) {
				return name.matches(".+\\.py$");
			}
		});
		
		
		Structure101Logger s101log = new Structure101Logger();
		IGoalEngineLogger logger = new CombinedLogger(s101log);
		inferencer = new PythonTypeInferencer(logger);
		
		LinkedList<String> sysPath = new LinkedList<String>();
		Workspace workspace = new Workspace(testsDirectory, sysPath);
		
		for (File file : files) {
			try {
				TestCase test = new TypeInferenceTest(file.getName(), file, workspace, inferencer, s101log);
				addTest(test);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
	}
	
	public void run(TestResult result) {
		super.run(result);
		inferencer.shutdown();
{'fraction_non_alphanumeric': 0.1638570465273095, 'fraction_numerical': 0.013486176668914362, 'mean_word_length': 5.3210227272727275, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2563196', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1232, 'n_words': 294}