Skip to content

Commit 21f9ca2

Browse files
committed
Keep testing data in-memory
1 parent dddabcc commit 21f9ca2

File tree

6 files changed

+66
-15
lines changed

6 files changed

+66
-15
lines changed

Maccy.xcodeproj/project.pbxproj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@
402402
DABDE97E2974706C005B32E9 /* KeyboardLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardLayout.swift; sourceTree = "<group>"; };
403403
DAC14123232367B200FCFA30 /* Search.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Search.swift; sourceTree = "<group>"; };
404404
DAC929D6297A0E8B00814F19 /* NSPasteboard.PasteboardType+Types.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSPasteboard.PasteboardType+Types.swift"; sourceTree = "<group>"; };
405+
DACCD5822C93605C00BAD74C /* Maccy.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = Maccy.xctestplan; sourceTree = "<group>"; };
405406
DAD665652898A1C000975096 /* KeyChord.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyChord.swift; sourceTree = "<group>"; };
406407
DADFF1382C2F58D000DB261D /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; };
407408
DAE284FF232257D20080E394 /* ColorImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorImage.swift; sourceTree = "<group>"; };
@@ -631,6 +632,7 @@
631632
DAEE38451E3DBEB100DD2966 /* Maccy */,
632633
DA360DB11E3DF137005C6F6B /* MaccyTests */,
633634
DA0EE7B7204657830025FC60 /* MaccyUITests */,
635+
DACCD5822C93605C00BAD74C /* Maccy.xctestplan */,
634636
DA00992C256411F90030E697 /* appcast.xml */,
635637
DA00992F256411F90030E697 /* LICENSE */,
636638
DA00992D256411F90030E697 /* README.md */,
@@ -1304,7 +1306,7 @@
13041306
PRODUCT_NAME = "$(TARGET_NAME)";
13051307
PROVISIONING_PROFILE_SPECIFIER = "";
13061308
SWIFT_VERSION = 5.0;
1307-
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Maccy.app/Contents/MacOS/Maccy";
1309+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Maccy.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Maccy";
13081310
};
13091311
name = Debug;
13101312
};
@@ -1328,7 +1330,7 @@
13281330
PRODUCT_NAME = "$(TARGET_NAME)";
13291331
PROVISIONING_PROFILE_SPECIFIER = "";
13301332
SWIFT_VERSION = 5.0;
1331-
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Maccy.app/Contents/MacOS/Maccy";
1333+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Maccy.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Maccy";
13321334
};
13331335
name = Release;
13341336
};
@@ -1462,7 +1464,7 @@
14621464
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
14631465
CODE_SIGN_STYLE = Automatic;
14641466
COMBINE_HIDPI_IMAGES = YES;
1465-
CURRENT_PROJECT_VERSION = 46;
1467+
CURRENT_PROJECT_VERSION = 47;
14661468
DEAD_CODE_STRIPPING = YES;
14671469
DEVELOPMENT_TEAM = MN3X4648SC;
14681470
ENABLE_HARDENED_RUNTIME = YES;
@@ -1497,7 +1499,7 @@
14971499
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
14981500
CODE_SIGN_STYLE = Automatic;
14991501
COMBINE_HIDPI_IMAGES = YES;
1500-
CURRENT_PROJECT_VERSION = 46;
1502+
CURRENT_PROJECT_VERSION = 47;
15011503
DEAD_CODE_STRIPPING = YES;
15021504
DEVELOPMENT_TEAM = MN3X4648SC;
15031505
ENABLE_HARDENED_RUNTIME = YES;
@@ -1530,7 +1532,7 @@
15301532
DA0EE7BE204657840025FC60 /* Release */,
15311533
);
15321534
defaultConfigurationIsVisible = 0;
1533-
defaultConfigurationName = Release;
1535+
defaultConfigurationName = Debug;
15341536
};
15351537
DA360DB71E3DF137005C6F6B /* Build configuration list for PBXNativeTarget "MaccyTests" */ = {
15361538
isa = XCConfigurationList;
@@ -1539,7 +1541,7 @@
15391541
DA360DB91E3DF137005C6F6B /* Release */,
15401542
);
15411543
defaultConfigurationIsVisible = 0;
1542-
defaultConfigurationName = Release;
1544+
defaultConfigurationName = Debug;
15431545
};
15441546
DAEE383E1E3DBEB100DD2966 /* Build configuration list for PBXProject "Maccy" */ = {
15451547
isa = XCConfigurationList;
@@ -1548,7 +1550,7 @@
15481550
DAEE384F1E3DBEB100DD2966 /* Release */,
15491551
);
15501552
defaultConfigurationIsVisible = 0;
1551-
defaultConfigurationName = Release;
1553+
defaultConfigurationName = Debug;
15521554
};
15531555
DAEE38501E3DBEB100DD2966 /* Build configuration list for PBXNativeTarget "Maccy" */ = {
15541556
isa = XCConfigurationList;
@@ -1557,7 +1559,7 @@
15571559
DAEE38521E3DBEB100DD2966 /* Release */,
15581560
);
15591561
defaultConfigurationIsVisible = 0;
1560-
defaultConfigurationName = Release;
1562+
defaultConfigurationName = Debug;
15611563
};
15621564
/* End XCConfigurationList section */
15631565

Maccy.xctestplan

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"configurations" : [
3+
{
4+
"id" : "AF4E53A3-F52D-4A3E-B9EF-EF728B4C1AAA",
5+
"name" : "Test Scheme Action",
6+
"options" : {
7+
8+
}
9+
}
10+
],
11+
"defaultOptions" : {
12+
"commandLineArgumentEntries" : [
13+
{
14+
"argument" : "enable-testing"
15+
}
16+
],
17+
"targetForVariableExpansion" : {
18+
"containerPath" : "container:Maccy.xcodeproj",
19+
"identifier" : "DAEE38421E3DBEB100DD2966",
20+
"name" : "Maccy"
21+
},
22+
"testRepetitionMode" : "retryOnFailure"
23+
},
24+
"testTargets" : [
25+
{
26+
"target" : {
27+
"containerPath" : "container:Maccy.xcodeproj",
28+
"identifier" : "DA360DAF1E3DF137005C6F6B",
29+
"name" : "MaccyTests"
30+
}
31+
},
32+
{
33+
"target" : {
34+
"containerPath" : "container:Maccy.xcodeproj",
35+
"identifier" : "DA0EE7B5204657830025FC60",
36+
"name" : "MaccyUITests"
37+
}
38+
}
39+
],
40+
"version" : 1
41+
}

Maccy/AppDelegate.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
2323

2424
private var statusItemVisibilityObserver: NSKeyValueObservation?
2525

26-
func applicationWillFinishLaunching(_ notification: Notification) {
27-
if ProcessInfo.processInfo.arguments.contains("ui-testing") {
26+
func applicationWillFinishLaunching(_ notification: Notification) { // swiftlint:disable:this function_body_length
27+
#if DEBUG
28+
if CommandLine.arguments.contains("enable-testing") {
2829
SPUUpdater(hostBundle: Bundle.main,
2930
applicationBundle: Bundle.main,
3031
userDriver: SPUStandardUserDriver(hostBundle: Bundle.main, delegate: nil),
3132
delegate: nil)
3233
.automaticallyChecksForUpdates = false
3334
}
35+
#endif
3436

3537
// Bridge FloatingPanel via AppDelegate.
3638
AppState.shared.appDelegate = self

Maccy/Storage.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ class Storage {
88
var container: ModelContainer
99
var context: ModelContext { container.mainContext }
1010

11+
private let url = URL.applicationSupportDirectory.appending(path: "Maccy/Storage.sqlite")
12+
1113
init() {
12-
let config = ModelConfiguration(url: URL.applicationSupportDirectory.appending(path: "Maccy/Storage.sqlite"))
14+
var config = ModelConfiguration(url: url)
15+
16+
#if DEBUG
17+
if CommandLine.arguments.contains("enable-testing") {
18+
config = ModelConfiguration(isStoredInMemoryOnly: true)
19+
}
20+
#endif
21+
1322
do {
1423
container = try ModelContainer(for: HistoryItem.self, configurations: config)
1524
} catch let error {

Maccy/Views/ContentView.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ struct ContentView: View {
3636
}
3737
.task {
3838
try? await appState.history.load()
39-
if ProcessInfo.processInfo.arguments.contains("ui-testing") {
40-
appState.history.clearAll()
41-
}
4239
}
4340
}
4441
.environment(appState)

MaccyUITests/MaccyUITests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class MaccyUITests: XCTestCase {
4646

4747
override func setUp() {
4848
super.setUp()
49-
app.launchArguments.append("ui-testing")
49+
app.launchArguments.append("enable-testing")
5050
app.launch()
5151

5252
copyToClipboard(copy2)

0 commit comments

Comments
 (0)