public static void CopySampledSequences(string sampleFile) { string[] files = File.ReadAllLines(sampleFile); foreach (var line in files) { string destDir = line.Replace(@"D:\Experiment\data-cleaner\apcs", @"D:\Experiment\apcs_sample"); int end = line.LastIndexOf('\\'); string str = line.Substring(0, end); string secretFile = str + @"\solution.cs"; end = str.LastIndexOf('\\'); str = str.Substring(end + 1); string newSecretFile = @"D:\Experiment\apcs_sample\" + str + @"\solution.cs"; FileModifier.CopyDirectory(line, destDir); File.Copy(secretFile, newSecretFile, true); } }
public static void GenerateRandomTests(string topDir, int numOfTests) { foreach (string taskDir in Directory.GetDirectories(topDir)) { MethodInfo method = null; foreach (var studentDir in Directory.GetDirectories(taskDir)) { if (studentDir.EndsWith("secret_project")) { string assemblyFile = FileModifier.GetAssemblyFileOfProject(studentDir); method = RunTest.GetMethodDefinition(assemblyFile, "Program", "Puzzle"); List <Test> tests = GenerateTestsForProject(method, numOfTests); string fileName = studentDir + @"\RandomTests.xml"; Serializer.SerializeTests(tests, fileName); break; } } } }
private void button1_Click(object sender, EventArgs e) { try { string topDir = @"C:\Users\admin\Dropbox\Thac si\Luan van\Projects\Demo Paper\Pex4Fun\DOTUONGTU\bin\Debug\Data"; FileModifier.MakeProjects(topDir); FileModifier.MakeSecretProjects(topDir); BuildDirectory.BuildProjects(topDir, true); BuildDirectory.BuildSecretProjects(topDir, true); FileModifier.MakeMetaProjects(topDir); BuildDirectory.BuildMetaProjects(topDir, true); BuildDirectory.CheckNotBuiltProjects(topDir); RunPex.RunPexOnSecretProjects(topDir); RunPex.RunPexOnMetaProjects(topDir); ExtractPexResults.ExtractPexTests(topDir); Metrics.ComputeMetric1(topDir); Metrics.ComputeMetric2(topDir); RandomTestGenerator.GenerateRandomTests(topDir, 200); Metrics.ComputeMetric3(topDir); //Console.WriteLine(Utility.GetNumOfStudent(topDir)); //Console.WriteLine(Utility.GetNumOfSubmissions(topDir);) lb_thongbao.Text = "Đã hoàn thành."; } catch { lb_thongbao.Text = "Code upload bị lỗi, kiểm tra lại..."; } //bt_rs.Enabled = true; //bt_sse.Enabled = true; //bt_pse.Enabled = true; }
public static void ExtractPexTests(string topDir) { foreach (string taskDir in Directory.GetDirectories(topDir)) { MethodInfo method = null; foreach (var studentDir in Directory.GetDirectories(taskDir)) { if (studentDir.EndsWith("secret_project")) { string assemblyFile = FileModifier.GetAssemblyFileOfProject(studentDir); method = RunTest.GetMethodDefinition(assemblyFile, "Program", "Puzzle"); List <Test> tests = ExtractTestsForProject(studentDir, method); if (tests != null) { string fileName = studentDir + @"\PexTests.xml"; Serializer.SerializeTests(tests, fileName); } break; } } foreach (var studentDir in Directory.GetDirectories(taskDir)) { if (studentDir.EndsWith("secret_project")) { continue; } foreach (var projectDir in Directory.GetDirectories(studentDir)) { List <Test> tests = ExtractTestsForProject(projectDir, method); if (tests != null) { string fileName = projectDir + @"\PexTests.xml"; Serializer.SerializeTests(tests, fileName); } } } } }