Skip to content

Instantly share code, notes, and snippets.

@satob
Created December 25, 2021 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satob/aca96e0b575dd460f608337d845227ab to your computer and use it in GitHub Desktop.
Save satob/aca96e0b575dd460f608337d845227ab to your computer and use it in GitHub Desktop.
OpenCloverのテスト用にjtregのテストケースからJavaの文法を網羅するテストスイートを作ろうとした(失敗)
# OpenCloverのテスト用にjtregのテストケースからJavaの文法を網羅するテストスイートを作ろうとしたけど
# jtregのテストはtestngとか外部のライブラリを必要とする物が多く断念
$AntContent = @'
<project>
<property environment="env"/>
<property name="clover.jar" location="${env.CLOVER_HOME}/lib/clover.jar"/>
<taskdef resource="cloverlib.xml" classpath="${clover.jar}"/>
<path id="classpath">
<pathelement path="${clover.jar}"/>
</path>
<target name="with.clover">
<clover-setup/>
</target>
<target name="clover.html">
<clover-html-report outdir="coverage"/>
</target>
<target name="clean">
<delete>
<fileset dir="." includes="*.class"/>
</delete>
<delete dir="coverage" />
<clover-clean/>
</target>
<target name="compile">
<javac classpathref="classpath" srcdir="." destdir="." includeantruntime="false"/>
</target>
<target name="run" depends="compile">
<java classpath="${clover.jar};." classname="T6517728A" />
<java classpath="${clover.jar};." classname="T6517728B" />
</target>
</project>
'@
$RootDirectory = (pwd);
Get-ChildItem -Recurse | Where-Object { $_.Name -like "*.java" } | ForEach-Object {
$FullName = $_.FullName;
$DirectoryName = $_.DirectoryName;
$FileName = $_.Name;
$Package = $false;
Get-Content $FullName | ForEach-Object {
if ($_ -match '^package (.+);$') {
$Package = $Matches[1]; return;
}
};
if ($Package -ne $false) {
Write-Host $FullName;
Write-Host $Package;
$PackagePath = $Package.Replace('.','\');
if ($FullName -like "*\${PackagePath}\${FileName}") {
Write-Host "OK";
$DirectoryName;
} else {
Write-Host "NG"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment