public static string InsertInstrumentationCode(LanguageSupport mode, string fileName) { var info = new CoverageInfo( Fixture.GetCoverageInputPath(), mode.Name, SharingMethod.SharedMemory); var inPath = Path.Combine(Fixture.GetCoverageInputPath(), fileName); var code = OccfCodeGenerator.GetCoveragedCode(new FileInfo(inPath), info, mode); File.WriteAllText(Fixture.GetOutputPath(fileName), code); return(code); }
private static void WriteTestCodeFiles( DirectoryInfo rootDir, DirectoryInfo testDir, LanguageSupport prof, TestInfo info) { var paths = prof.FilePatterns.SelectMany( pattern => testDir.EnumerateFiles( pattern, SearchOption.AllDirectories)); foreach (var path in paths.ToList()) { var backPath = Path.Combine(rootDir.FullName, path.FullName + OccfNames.BackupSuffix); path.CopyTo(backPath, true); //バックアップファイルの上書き可 var outPath = OccfCodeGenerator.AnalyzeAndWriteIdentifiedTest(prof, info, path, rootDir); Console.WriteLine("wrote:" + outPath); } }
private static void WriteProductionCodeFiles( DirectoryInfo rootDir, IEnumerable <FileInfo> fileInfos, LanguageSupport mode, CoverageInfo info) { foreach (var path in fileInfos) { // 対象ファイルに対してKlee_backやLine_backがあるときは作成しない // Avoid ge if (!(File.Exists(path.FullName + OccfNames.LineBackUpSuffix)) && !(File.Exists(path.FullName + OccfNames.KleeBackUpSuffix))) { var backPath = Path.Combine(rootDir.FullName, path.FullName + OccfNames.BackupSuffix); path.CopyTo(backPath, true); } var outPath = OccfCodeGenerator.WriteCoveragedCode(mode, info, path, rootDir); Console.WriteLine("wrote:" + outPath); } }
public void Should_Insert_Measurement_Code_In_JUnit4_Code(string fileName) { var info = new TestInfo(Fixture.GetTestInputPath()); var inPath = Path.Combine(Fixture.GetTestInputPath(), fileName); var code = OccfCodeGenerator.GetIdentifiedTest( new FileInfo(inPath), info, LanguageSupports.GetCoverageModeByClassName("Java")); var expPath = Path.Combine(Fixture.GetTestExpectationPath(), fileName); using (var reader = new StreamReader(expPath)) { var expected = reader.ReadToEnd(); try { Assert.That(code, Is.EqualTo(expected)); } catch { var path = Fixture.GetOutputPath(fileName); File.WriteAllText(path, code); throw; } } }
private void BtnStartClick(object sender, EventArgs e) { var files = clbFiles.CheckedItems.Cast <string>(); var basePath = txtBase.Text.AddIfNotEndsWith('\\'); var outDirPath = txtOutput.Text.AddIfNotEndsWith('\\'); var filePathList = files.ToList(); var langName = cmbLanguage.Text; Action action = () => { var profile = LanguageSupports.GetCoverageModeByClassName(langName); var info = new CoverageInfo(basePath, profile.Name, SharingMethod.File); var outDir = new DirectoryInfo(outDirPath); foreach (var filePath in filePathList) { OccfCodeGenerator.WriteCoveragedCode( profile, info, new FileInfo(filePath), outDir); } info.Write(new DirectoryInfo(outDirPath)); }; ProgressForm.Start(this, filePathList.Count, action); }