<commit_before>package net.exkazuu.probe

import java.io.File
import java.util.List
import net.exkazuu.probe.git.GitManager
import net.exkazuu.probe.github.GithubRepositoryInfo
import net.exkazuu.probe.maven.XMutatorManager

/**
 * A class for measuring mutation scores by executing XMutator.
 * 
 * @author <NAME>
 */
class XMutatorExecutor {
	protected val File csvFile
	protected val List<GithubRepositoryInfo> infos
	val File mvnDir
	val int skipCount

	new(File csvFile, File mvnDir, int skipCount) {
		this.csvFile = csvFile
		this.infos = GithubRepositoryInfo.readList(csvFile)
		this.mvnDir = mvnDir
		this.skipCount = skipCount
		mvnDir.mkdirs()
	}

	def run() {
		infos.drop(skipCount).forEach [ info, i |
			try {
				if (info.killedMutantPercentageWithXMutator >= 0) {
					System.out.println((i + skipCount + 1) + ": " + info.url)
					val userDir = new File(mvnDir.path, info.userName)
					val projectDir = new File(userDir.path, info.projectName)
					userDir.mkdirs()
					System.out.print("Clone and checkout ... ")
					new GitManager(projectDir).cloneAndCheckout(info.url, info.mainBranch, "origin/" + info.mainBranch)
					System.out.println("done")
					execiteXMutator(info, projectDir)
					GithubRepositoryInfo.write(csvFile, infos)
					return
				}
			} catch (Exception e) {
				e.printStackTrace
			}
		]
	}

	def void execiteXMutator(GithubRepositoryInfo info, File projectDir) {
		System.out.print("Execute XMutator ... ")
		val xm = new XMutatorManager(projectDir)
		val ret = xm.execute()
		val vals = ret.key
		if (vals != null && vals.size >= 3) {
			info.killedMutantCountWithXMutator = vals.get(0)
			info.generatedMutantCountWithXMutator = vals.get(1)
			info.killedMutantPercentageWithXMutator = vals.get(2)
			System.out.println("successful " + vals)
		} else {
			info.killedMutantCountWithXMutator = -2
			info.generatedMutantCountWithXMutator = -2
			info.killedMutantPercentageWithXMutator = -2
			System.out.println("failed")
		}
		System.out.println(ret.value.join("\n"))
	}

	def static void main(String[] args) {
		if (args.length <= 1) {
			System.out.println("Please specify two argument indicating a csv file and a skip count.")
			System.exit(-1)
		}

		val csvFile = new File(args.get(0))
		val skipCount = Integer.parseInt(args.get(1))
		val executor = new XMutatorExecutor(csvFile, new File("repos"), skipCount)
		executor.run()
	}
}
<commit_msg>Fix XMutatorExecutor to use the latest XMutator correctly.<commit_after>package net.exkazuu.probe

import java.io.File
import java.util.List
import net.exkazuu.probe.git.GitManager
import net.exkazuu.probe.github.GithubRepositoryInfo
import net.exkazuu.probe.maven.XMutatorManager

/**
 * A class for measuring mutation scores by executing XMutator.
 * 
 * @author <NAME>
 */
class XMutatorExecutor {
	protected val File csvFile
	protected val List<GithubRepositoryInfo> infos
	val File mvnDir
	val int skipCount

	new(File csvFile, File mvnDir, int skipCount) {
		this.csvFile = csvFile
		this.infos = GithubRepositoryInfo.readList(csvFile)
		this.mvnDir = mvnDir
		this.skipCount = skipCount
		mvnDir.mkdirs()
	}

	def run() {
		infos.drop(skipCount).forEach [ info, i |
			try {
				if (info.killedMutantPercentageWithXMutator >= 0) {
					System.out.println((i + skipCount + 1) + ": " + info.url)
					val userDir = new File(mvnDir.path, info.userName)
					val projectDir = new File(userDir.path, info.projectName)
					userDir.mkdirs()
					System.out.print("Clone and checkout ... ")
					new GitManager(projectDir).cloneAndCheckout(info.url, info.mainBranch, "origin/" + info.mainBranch)
					System.out.println("done")
					execiteXMutator(info, projectDir)
					GithubRepositoryInfo.write(csvFile, infos)
					return
				}
			} catch (Exception e) {
				e.printStackTrace
			}
		]
	}

	def void execiteXMutator(GithubRepositoryInfo info, File projectDir) {
		System.out.print("Execute XMutator ... ")
		val xm = new XMutatorManager(projectDir)
		val ret = xm.execute()
		val vals = ret.key
		if (vals != null && vals.size >= 4) {
			info.killedMutantCountWithXMutator = vals.get(0)
			info.generatedMutantCountWithXMutator = vals.get(2)
			info.killedMutantPercentageWithXMutator = vals.get(3)
			System.out.println("successful " + vals)
		} else {
			info.killedMutantCountWithXMutator = -2
			info.generatedMutantCountWithXMutator = -2
			info.killedMutantPercentageWithXMutator = -2
			System.out.println("failed")
		}
		System.out.println(ret.value.join("\n"))
	}

	def static void main(String[] args) {
		if (args.length <= 1) {
			System.out.println("Please specify two argument indicating a csv file and a skip count.")
			System.exit(-1)
		}

		val csvFile = new File(args.get(0))
		val skipCount = Integer.parseInt(args.get(1))
		val executor = new XMutatorExecutor(csvFile, new File("repos"), skipCount)
		executor.run()
	}
}

{'fraction_non_alphanumeric': 0.11615432226119249, 'fraction_numerical': 0.005364142768722922, 'mean_word_length': 3.843156843156843, 'pattern_counts': {'":': 2, '<': 9, '<?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': '3745792', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1668, 'n_words': 351}