REGRESSION (r216711): API test WKWebView.ClearAppCache is failing.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 May 2017 20:09:25 +0000 (20:09 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 May 2017 20:09:25 +0000 (20:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172030

Unreviewed - Test gardening, in effect...

This failure is only being seen by the bots.

I believe this test is utterly broken in the first place; when it checks the .wal file's
size that is not actually an indicator that the records were deleted.

But that isn't what's coming up as failure on the bots.

This patch is an attempt to:
1 - More forcefully clear the Website data directory of leftovers before the test starts.
2 - Give an earlier indication of the failure that the bots are seeing, to possibly reveal more.

* TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm:
(defaultWebsiteDataDirectory):
(defaultApplicationCacheDirectory):
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216777 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm

index 4e655ee..c592a80 100644 (file)
@@ -1,3 +1,26 @@
+2017-05-12  Brady Eidson  <beidson@apple.com>
+
+        REGRESSION (r216711): API test WKWebView.ClearAppCache is failing.
+        https://bugs.webkit.org/show_bug.cgi?id=172030
+
+        Unreviewed - Test gardening, in effect...
+
+        This failure is only being seen by the bots.
+        
+        I believe this test is utterly broken in the first place; when it checks the .wal file's
+        size that is not actually an indicator that the records were deleted.
+        
+        But that isn't what's coming up as failure on the bots.
+        
+        This patch is an attempt to:
+        1 - More forcefully clear the Website data directory of leftovers before the test starts.
+        2 - Give an earlier indication of the failure that the bots are seeing, to possibly reveal more.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm:
+        (defaultWebsiteDataDirectory):
+        (defaultApplicationCacheDirectory):
+        (TEST):
+
 2017-05-12  Jonathan Bedard  <jbedard@apple.com>
 
         webkitpy: Pass directory with crash logs into CrashLogs
index eab87e0..12dbce3 100644 (file)
@@ -107,13 +107,22 @@ NSString *swizzledBundleIdentifierWebBookmarksD()
     return @"com.apple.webbookmarksd";
 }
 
+NSString *defaultWebsiteDataDirectory()
+{
+#if PLATFORM(IOS)
+    return nil;
+#else
+    return @"~/Library/Caches/TestWebKitAPI/WebKit";
+#endif
+}
+
 NSString *defaultApplicationCacheDirectory()
 {
 #if PLATFORM(IOS)
     // This is to mirror a quirk in WebsiteDataStore::defaultApplicationCacheDirectory and catch any regressions.
     return [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches/com.apple.WebAppCache"];
 #else
-    return @"~/Library/Caches/TestWebKitAPI/WebKit/OfflineWebApplicationCache";
+    return [defaultWebsiteDataDirectory() stringByAppendingString:@"/OfflineWebApplicationCache"];
 #endif
 }
 
@@ -126,22 +135,24 @@ TEST(WKWebView, ClearAppCache)
     NSURL *dbResourceURL = [[NSBundle mainBundle] URLForResource:@"ApplicationCache" withExtension:@"db" subdirectory:@"TestWebKitAPI.resources"];
     NSURL *shmResourceURL = [[NSBundle mainBundle] URLForResource:@"ApplicationCache" withExtension:@"db-shm" subdirectory:@"TestWebKitAPI.resources"];
     NSURL *walResourceURL = [[NSBundle mainBundle] URLForResource:@"ApplicationCache" withExtension:@"db-wal" subdirectory:@"TestWebKitAPI.resources"];
-    
+
+    // Clean up any website data files left from any previous test run.
+    if (auto *websiteDataDirectory = defaultWebsiteDataDirectory()) {
+        NSURL *websiteDataURL = [NSURL fileURLWithPath:[websiteDataDirectory stringByExpandingTildeInPath]];
+        [[NSFileManager defaultManager] removeItemAtURL:websiteDataURL error:nil];
+    }
+
     NSURL *targetURL = [NSURL fileURLWithPath:[defaultApplicationCacheDirectory() stringByExpandingTildeInPath]];
     [[NSFileManager defaultManager] createDirectoryAtURL:targetURL withIntermediateDirectories:YES attributes:nil error:nil];
-    
+
     NSURL *dbTargetURL = [targetURL URLByAppendingPathComponent:@"ApplicationCache.db"];
     NSURL *walTargetURL = [targetURL URLByAppendingPathComponent:@"ApplicationCache.db-wal"];
     NSURL *shmTargetURL = [targetURL URLByAppendingPathComponent:@"ApplicationCache.db-shm"];
 
-    // Clean up any files that may have been left from this test failing before.
-    [[NSFileManager defaultManager] removeItemAtURL:dbTargetURL error:nil];
-    [[NSFileManager defaultManager] removeItemAtURL:walTargetURL error:nil];
-    [[NSFileManager defaultManager] removeItemAtURL:shmTargetURL error:nil];
     EXPECT_EQ(fileSize(dbTargetURL), -1);
     EXPECT_EQ(fileSize(walTargetURL), -1);
     EXPECT_EQ(fileSize(shmTargetURL), -1);
-    
+
     // Copy the resources from the bundle to ~/Library/...
     [[NSFileManager defaultManager] copyItemAtURL:dbResourceURL toURL:dbTargetURL error:nil];
     [[NSFileManager defaultManager] copyItemAtURL:shmResourceURL toURL:shmTargetURL error:nil];
@@ -156,7 +167,7 @@ TEST(WKWebView, ClearAppCache)
     readyToContinue = false;
     [[WKWebsiteDataStore defaultDataStore] fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] completionHandler:^(NSArray<WKWebsiteDataRecord *> *websiteDataRecords)
     {
-        EXPECT_GT(websiteDataRecords.count, 0ul);
+        EXPECT_EQ(websiteDataRecords.count, 1ul);
         originalWebsiteDataRecordCount = websiteDataRecords.count;
         readyToContinue = true;
     }];