Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SwiftTestTool] Add support for parallel test execution. #583

Merged
merged 1 commit into from Sep 24, 2016

Conversation

ankitspd
Copy link
Member

@ankitspd ankitspd commented Aug 1, 2016

No description provided.

@ankitspd ankitspd force-pushed the parallel-tests branch 2 times, most recently from b5b5038 to c035ecd Compare August 1, 2016 13:23
private let progressBar: ProgressBarProtocol

/// A lock to update progress bar status.
private var progressBarLock = Basic.Lock()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using a lock, I would expect a single status reporting thread which consumes items from the status queue (serially).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(in this case, run() would probably be the consumer rather than a separate thread)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so errors will printed during the progress?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or have a separate queue for status?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, they are both part of status reporting in general...

@ddunbar
Copy link
Member

ddunbar commented Aug 1, 2016

Looks like a reasonable start to me, I added a couple minor comments inline and we should try and get at least a minimal functional test (OS X only, for now, due to testing infrastructure) in.

@ankitspd ankitspd force-pushed the parallel-tests branch 4 times, most recently from 8729577 to be37bcc Compare September 21, 2016 11:24
@ankitspd ankitspd assigned ddunbar and unassigned ankitspd Sep 21, 2016
@ankitspd
Copy link
Member Author

ankitspd commented Sep 21, 2016

@ddunbar Updated

pendingTests.enqueue(testCase.name + "/" + test)
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels weird to initialize the pendingTests queue in the initializer but consume it inside run(). Any reason not to just to it in run?

private let pendingTests = SynchronizedQueue<String?>()

/// The queue containing output of failed tests.
private let failedTests = SynchronizedQueue<String?>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have a queue for failed and a queue for finished? Also, wouldn't it be nice to have a structured object inside the queue rather than just String?

@ankitspd
Copy link
Member Author

@ddunbar Updated

/// Updates the progress bar status.
private func updateProgress(for test: UnitTest) {
numCurrentTest += 1
progressBar.update(percent: 100*numCurrentTest/numTests, text: "test :: \(test.specifier)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, btw we should just drop the test :: it doesn't really make sense for us.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@ddunbar
Copy link
Member

ddunbar commented Sep 24, 2016

LGTM

Adds a new `--parallel` mode to SwiftTestTool which spawns threads to
execute the tests in parallel. The number of threads spawned is
determined by the active processor count. The tests are executed in
parallel by first determining test specifiers and then executing one
specifier per thread.
@ankitspd ankitspd merged commit dd677d0 into apple:master Sep 24, 2016
@ankitspd ankitspd deleted the parallel-tests branch September 26, 2016 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants