void RunCopyingOnSeparateThread() { foreach (var config in this.configs) { CCreateSyncResultsSet results = null; string sExceptionOccurred = null; try { string sLogFilename = RunImplementation.GetLogFilename(); RunImplementation.Go(config, sLogFilename, preview, false); results = CCreateSyncResultsSet.ParseFromLogFile( config, sLogFilename, preview); } catch (Exception e) { sExceptionOccurred = e.ToString(); } Action action = delegate() { OnRunComplete(results, sExceptionOccurred); }; btnToTemporarilyDisable.BeginInvoke(action); } // Don't restore btn text until all configs were processed Action restoreBtnText = delegate() { btnToTemporarilyDisable.Text = sPreviousButtonName; btnToTemporarilyDisable.Enabled = true; }; btnToTemporarilyDisable.BeginInvoke(restoreBtnText); }
static void TestMethod_TestIndividualFailures() { var sDirectory = Testing.SetUpSynctestEnvironment(); CCreateSyncResultsSet results; CCreateSyncResultsSet.showWarnings = false; using (Stream iStream2 = File.Open(sDirectory + "\\src\\Licenses\\OpenSsl-License.txt", FileMode.Append, FileAccess.Write, FileShare.None)) { var config = GetRealConfig(sDirectory, 4 /*nThreads*/); config.m_nRetries = "1"; config.m_waitBetweenRetries = "1"; string sLogFilename = RunImplementation.GetLogFilename(); RunImplementation.Go(config, sLogFilename, false /*preview*/, false); results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, false /*preview*/); File.Delete(sLogFilename); } CCreateSyncResultsSet.showWarnings = true; Utils.AssertEq(0, results.items.Count); Utils.AssertEq(true, results.sSummary.Contains("Summary indicated failures")); Utils.AssertEq(true, results.sSummary.Contains("*EXTRA File")); Utils.AssertEq(true, results.sSummary.Contains("it is being used by another process")); Utils.AssertEq(true, results.sSummary.Contains("RETRY LIMIT EXCEEDED")); Utils.AssertEq(true, results.sSummary.Contains("Bytes :")); }
static void TestMethod_TestGlobalFailure() { var config = new SyncConfiguration(); config.m_src = "notexist1"; config.m_destination = "notexist2"; config.m_mirror = true; config.m_copySubDirsAndEmptySubdirs = true; string sLogFilename = RunImplementation.GetLogFilename(); RunImplementation.Go(config, sLogFilename, true /*preview*/, false); var results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, true /*preview*/); Utils.AssertEq(0, results.items.Count); Utils.AssertEq(true, results.sSummary.Contains("looks like errors occurred:")); Utils.AssertEq(true, results.sSummary.Contains("The system cannot find the file specified.")); File.Delete(sLogFilename); }
private static void TestSyncPreview(string sDirectory, int nThreads) { var config = GetRealConfig(sDirectory, nThreads); string sLogFilename = RunImplementation.GetLogFilename(); RunImplementation.Go(config, sLogFilename, true /*preview*/, false); var results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, true /*preview*/); // the number of skipped dirs is 3 instead of the 2 it used to be, but not important right now Utils.AssertEq("Total Copied Skipped Mismatch Failed Extras\r\n Dirs : 5 5 3 0 0 2\r\n Files : 22 8 14 0 0 2\r\n Bytes : 632.0 k 126.6 k 505.4 k 0 0 30.7 k", results.sSummary.Trim()); File.Delete(sLogFilename); { CCreateSyncItem.SortFromColumnNumber(results.items, 3); // sort by path ascending var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString(); var sGot = String.Join("\n", resultsFilteredStrings); var sExpected = @"Create \Images\a.png Create \Images\addir\a.PNG Delete \Images\new.png Delete \Images\remdir\c.png Create \Licenses\.weirdext Update \Licenses\Apr-License.txt Update() \Licenses\Cyrus-Sasl-License.txt Create \Licenses\noext Update() \Licenses\OpenSsl-License.txt Update \Licenses\Serf-License.txt" .Replace("\r\n", "\n"); Utils.AssertEq(sExpected, sGot); } { CCreateSyncItem.SortFromColumnNumber(results.items, -3); // sort by path descending var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString(); var sGot = String.Join("\n", resultsFilteredStrings); var sExpected = @"Update \Licenses\Serf-License.txt Update() \Licenses\OpenSsl-License.txt Create \Licenses\noext Update() \Licenses\Cyrus-Sasl-License.txt Update \Licenses\Apr-License.txt Create \Licenses\.weirdext Delete \Images\remdir\c.png Delete \Images\new.png Create \Images\addir\a.PNG Create \Images\a.png" .Replace("\r\n", "\n"); Utils.AssertEq(sExpected, sGot); } { CCreateSyncItem.SortFromColumnNumber(results.items, 1); // sort by type where Update() != Update var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString(); var sGot = String.Join("\n", resultsFilteredStrings); var sExpected = @"Create \Images\a.png Create \Images\addir\a.PNG Create \Licenses\.weirdext Create \Licenses\noext Delete \Images\new.png Delete \Images\remdir\c.png Update \Licenses\Apr-License.txt Update \Licenses\Serf-License.txt Update() \Licenses\Cyrus-Sasl-License.txt Update() \Licenses\OpenSsl-License.txt" .Replace("\r\n", "\n"); Utils.AssertEq(sExpected, sGot); } { CCreateSyncItem.SortFromColumnNumber(results.items, 2); // sort by type where Update() == Update var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString(); var sGot = String.Join("\n", resultsFilteredStrings); var sExpected = @"Create \Images\a.png Create \Images\addir\a.PNG Create \Licenses\.weirdext Create \Licenses\noext Delete \Images\new.png Delete \Images\remdir\c.png Update \Licenses\Apr-License.txt Update() \Licenses\Cyrus-Sasl-License.txt Update() \Licenses\OpenSsl-License.txt Update \Licenses\Serf-License.txt" .Replace("\r\n", "\n"); Utils.AssertEq(sExpected, sGot); } }
static void TestActualSync(string sDirectory, int nThreads) { var config = GetRealConfig(sDirectory, nThreads); string sLogFilename = RunImplementation.GetLogFilename(); RunImplementation.Go(config, sLogFilename, false /*preview*/, false); var results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, false /*preview*/); File.Delete(sLogFilename); // the number of skipped dirs is 3 instead of the 2 it used to be, but not important right now Utils.AssertEq("Total Copied Skipped Mismatch Failed Extras\r\n Dirs : 5 5 3 0 0 2\r\n Files : 22 8 14 0 0 2\r\n Bytes : 632.0 k 126.6 k 505.4 k 0 0 30.7 k", results.sSummary.Trim()); // check files string[] filesExpected = @"..\..\test\testsync\dest ..\..\test\testsync\dest\Images ..\..\test\testsync\dest\Images\a.png ..\..\test\testsync\dest\Images\addempty ..\..\test\testsync\dest\Images\addir ..\..\test\testsync\dest\Images\addir\a.PNG ..\..\test\testsync\dest\Images\b.png ..\..\test\testsync\dest\Images\c.png ..\..\test\testsync\dest\Images\d.png ..\..\test\testsync\dest\Images\DB44-20-x64.jpg ..\..\test\testsync\dest\Images\e.png ..\..\test\testsync\dest\Images\f.gif ..\..\test\testsync\dest\Licenses ..\..\test\testsync\dest\Licenses\.weirdext ..\..\test\testsync\dest\Licenses\Apr-License.txt ..\..\test\testsync\dest\Licenses\Apr-Util-License.txt ..\..\test\testsync\dest\Licenses\BerkeleyDB-License.txt ..\..\test\testsync\dest\Licenses\Cyrus-Sasl-License.txt ..\..\test\testsync\dest\Licenses\GetText-Runtime-License.txt ..\..\test\testsync\dest\Licenses\noext ..\..\test\testsync\dest\Licenses\OpenSsl-License.txt ..\..\test\testsync\dest\Licenses\Serf-License.txt ..\..\test\testsync\dest\Licenses\SharpSvn-License.txt ..\..\test\testsync\dest\Licenses\Subversion-License.txt ..\..\test\testsync\dest\loren.html ..\..\test\testsync\dest\loren.txt ..\..\test\testsync\dest\pic1.png ..\..\test\testsync\src ..\..\test\testsync\src\Images ..\..\test\testsync\src\Images\a.png ..\..\test\testsync\src\Images\addempty ..\..\test\testsync\src\Images\addir ..\..\test\testsync\src\Images\addir\a.PNG ..\..\test\testsync\src\Images\b.png ..\..\test\testsync\src\Images\c.png ..\..\test\testsync\src\Images\d.png ..\..\test\testsync\src\Images\DB44-20-x64.jpg ..\..\test\testsync\src\Images\e.png ..\..\test\testsync\src\Images\f.gif ..\..\test\testsync\src\Licenses ..\..\test\testsync\src\Licenses\.weirdext ..\..\test\testsync\src\Licenses\Apr-License.txt ..\..\test\testsync\src\Licenses\Apr-Util-License.txt ..\..\test\testsync\src\Licenses\BerkeleyDB-License.txt ..\..\test\testsync\src\Licenses\Cyrus-Sasl-License.txt ..\..\test\testsync\src\Licenses\GetText-Runtime-License.txt ..\..\test\testsync\src\Licenses\noext ..\..\test\testsync\src\Licenses\OpenSsl-License.txt ..\..\test\testsync\src\Licenses\Serf-License.txt ..\..\test\testsync\src\Licenses\SharpSvn-License.txt ..\..\test\testsync\src\Licenses\Subversion-License.txt ..\..\test\testsync\src\loren.html ..\..\test\testsync\src\loren.txt ..\..\test\testsync\src\pic1.png".Replace("\r\n", "\n").Replace(@"..\..\test\testsync\", sDirectory + "\\").Split(new char[] { '\n' }); List <string> filesGot = Directory.GetFileSystemEntries(sDirectory, "*", SearchOption.AllDirectories).ToList(); filesGot.Sort(); Testing.AssertStringArrayEqual(filesExpected, filesGot); Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\Cyrus-Sasl-License.txt").Length, 1861L); Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\OpenSsl-License.txt").Length, 6286L); Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\Apr-License.txt").Length, 18324L); Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\Serf-License.txt").Length, 11562L); Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\Cyrus-Sasl-License.txt").Length, 1861L); Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\OpenSsl-License.txt").Length, 6286L); Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\Apr-License.txt").Length, 18324L); Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\Serf-License.txt").Length, 11562L); }