Skip to content

Commit

Permalink
Fix test wait for vim open to be more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
ychin committed Nov 4, 2023
1 parent fd8e46c commit 8957189
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/MacVim/MacVimTests/MacVimTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ @interface MacVimTests : XCTestCase

@implementation MacVimTests

/// Wait for Vim window to open and is ready to go
/// Wait for Vim window to open
- (void)waitForVimOpen {
XCTestExpectation *expectation = [self expectationWithDescription:@"VimOpen"];

Expand All @@ -61,7 +61,11 @@ - (void)waitForVimOpen {
method_setImplementation(method, newIMP);
[self waitForExpectations:@[expectation] timeout:10];
method_setImplementation(method, origIMP);
}

/// Wait for Vim window to open and is ready to go
- (void)waitForVimOpenAndWait {
[self waitForVimOpen];
[self waitForEventHandlingAndVimProcess];
}

Expand Down Expand Up @@ -259,7 +263,7 @@ - (void)testVimTutor {
// Adding a new window is necessary for the vimtutor menu to show up as it's
// not part of the global menu
[app openNewWindow:NewWindowClean activate:YES];
[self waitForVimOpen];
[self waitForVimOpenAndWait];

// Find the vimtutor menu and run it.
NSMenu *mainMenu = [NSApp mainMenu];
Expand All @@ -278,7 +282,7 @@ - (void)testVimTutor {
// Note that `vimtutor` opens Vim twice. Once to copy the file. Another time to
// actually open the copied file.
[self waitForVimOpen];
[self waitForVimOpen];
[self waitForVimOpenAndWait];

NSString *bufname = [[app keyVimController] evaluateVimExpression:@"bufname()"];
XCTAssertTrue([bufname containsString:@"tutor"]);
Expand All @@ -302,7 +306,7 @@ - (void)testHelpMenuDocumentationTag {

// Test help menu when no window is shown
[app performActionForItem:@[@"", @"m'"]];
[self waitForVimOpen];
[self waitForVimOpenAndWait];
MMVimController *vim = [app keyVimController];

XCTAssertEqualObjects(@"help", [vim evaluateVimExpression:@"&buftype"]);
Expand All @@ -314,7 +318,7 @@ - (void)testHelpMenuDocumentationTag {

// Test help menu when there's already a Vim window
[app openNewWindow:NewWindowClean activate:YES];
[self waitForVimOpen];
[self waitForVimOpenAndWait];
vim = [app keyVimController];

#define ASSERT_HELP_PATTERN(pattern) \
Expand Down Expand Up @@ -358,7 +362,7 @@ - (void) testCmdlineRowCalculation {
MMAppController *app = MMAppController.sharedInstance;

[app openNewWindow:NewWindowClean activate:YES];
[self waitForVimOpen];
[self waitForVimOpenAndWait];

MMTextView *textView = [[[[app keyVimController] windowController] vimView] textView];
const int numLines = [textView maxRows];
Expand Down

0 comments on commit 8957189

Please sign in to comment.