public void appendProjectPathsToGHTorrentCSV() { string ghMainProjectsFile = string.Format($"{clonedProjectsFolder}\\ghprojectsMain.csv"); string[] lines = File.ReadAllLines(ghprojectsFile); lines = lines.Distinct().ToArray(); string header = string.Format($"{lines[0]};projectPath;parentPath;ecosystem;projectName"); MiningUtility.createFileHeader(ghMainProjectsFile, header); StreamWriter writer = File.AppendText(ghMainProjectsFile); for (int i = 0; i < lines.Length; i++) { string line = lines[i]; int count = i; try { GHProject p = getrojectFolder(line); if (p != null) { writer.WriteLine($"{line};{p.ProjectFolder};{p.ParentPath};{p.ProjectName};{p.ProjectName}"); } //Task cloneTask = Task.Factory.StartNew(() => doClone(bag, line, writer, count, legnth)); //tasks.Add(cloneTask); Console.WriteLine($"Ecosystem number:{i}/{lines.Length}"); } catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.StackTrace); } } writer.Close(); }
public void generateFinalMainlineGHProjectsCSV() { //generating csv with final mainline repos string finalProjectsFile = string.Format($"{clonedProjectsFolder}\\ghprojectsFinalMainline.csv"); string header = "id;projectname;createdat;testcases"; MiningUtility.createFileHeader(finalProjectsFile, header); StreamWriter writer = File.AppendText(finalProjectsFile); DataController dc = new DataController(); SqlDataReader reader = dc.GetMainlineReposWithMoreThan20TestCases(); Console.WriteLine("Generating CSv with mainline repos that have more than 20 test cases: " + finalProjectsFile); while (reader.Read()) { writer.WriteLine($"{reader["ProjectID"]};{reader["ProjectName"]};{reader["CreatedAt"]};{reader["testcases"]}"); } reader.Close(); writer.Close(); }
public void detectTestCases() { DataController dc = new DataController(); var projects = MiningUtility.GetProjectGroups(); int projectCount = 0, projectsNumber = projects.Count(); string testCaseFileHeader = "project;parent;projectIsFork;testPackage;testClassName;testMethodName;testMethodParameters;testSourceFilePath;testStartingLine;testEndingLine;testStartingColumn;testEndingColumn;uutPackage;uutClassName;uutMethodName;uutMethodParameters;uutSourceFilePath;uutStartingLine;uutEndingLine;uutStartingColumn;uutEndingColumn"; MiningUtility.createFileHeader(testCasesFile, testCaseFileHeader); string classesHeader = "project;parent;projectIsFork;package;className;methodName;methodParameters;SourceFilePath;StartingLine;EndingLine;StartingColumn;EndingColumn"; MiningUtility.createFileHeader(classesAndMethodsFile, classesHeader); //extract clones per ecosystem foreach (ProjectGroup project in projects) { projectCount++; try { string projectFolder = project.ProjectFolder;// "C:\\grouped\\3_android_packages_apps_Contacts\\LineageOS\\android_packages_apps_Contacts"; TestCaseDetector testCaseDetector = new TestCaseDetector(projectFolder, srcMLLocation); testCaseDetector.AnalyzeTestCases(); HashSet <TestCaseID> allTestCases = testCaseDetector.AllTestCases; HashSet <TestCaseSummary> projectTestSummary = null; // new HashSet<TestCaseSummary>(); //projct parent string parent = project.Ecosystem; string projectName = project.Project; bool isFork = projectName != parent; Utilities.analyzeProjectTestCases(projectFolder, allTestCases, dc, srcMLLocation, testCasesFile, classesAndMethodsFile, projectName, parent, isFork); Console.WriteLine($"Ecosystem: {project.Ecosystem}; Project:{projectCount}/{projectsNumber}"); } catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.StackTrace); } } }