Update TestAction lauch arguments environments settings

This commit is contained in:
dangthaison91 2019-05-07 00:38:39 +07:00
parent 6d0d1e78ab
commit a481e4c1d0
5 changed files with 14 additions and 9 deletions

View File

@ -9,6 +9,7 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
### Added
- Adding generate command timer https://github.com/tuist/tuist/pull/335 by @kwridan
- Support Scheme manifest with pre/post action https://github.com/tuist/tuist/pull/336 by @dangthaison91
### Removed

View File

@ -62,8 +62,8 @@ public class Arguments: Codable {
case launch
}
public init(environment: [String: String],
launch: [String: Bool]) {
public init(environment: [String: String] = [:],
launch: [String: Bool] = [:]) {
self.environment = environment
self.launch = launch
}

View File

@ -200,11 +200,14 @@ final class SchemesGenerator: SchemesGenerating {
environments = environmentVariables(arguments.environment)
}
let shouldUseLaunchSchemeArgsEnv: Bool = args == nil && environments == nil
return XCScheme.TestAction(buildConfiguration: "Debug",
macroExpansion: nil,
testables: testables,
preActions: preActions,
postActions: postActions,
shouldUseLaunchSchemeArgsEnv: shouldUseLaunchSchemeArgsEnv,
codeCoverageEnabled: testAction.coverage,
commandlineArguments: args,
environmentVariables: environments)

View File

@ -13,18 +13,18 @@ final class SchemeTests: XCTestCase {
preActions: buildAction,
postActions: buildAction),
testAction: TestAction(targets: ["target"],
arguments: Arguments(environment: ["a": "b"],
launch: ["a": true]),
arguments: Arguments(environment: ["test": "b"],
launch: ["test": true]),
config: .debug,
coverage: true,
preActions: testAction,
postActions: testAction),
runAction: RunAction(config: .debug,
executable: "executable",
arguments: Arguments(environment: ["a": "b"],
launch: ["a": true])))
arguments: Arguments(environment: ["run": "b"],
launch: ["run": true])))
let expected = "{\"build_action\": {\"targets\": [\"target\"], \"pre_actions\": [{\"title\": \"Run Script\", \"script_text\": \"echo build_action\", \"target\": \"target\"}], \"post_actions\": [{\"title\": \"Run Script\", \"script_text\": \"echo build_action\", \"target\": \"target\"}]}, \"name\": \"scheme\", \"run_action\": {\"arguments\": {\"environment\": {\"a\": \"b\"}, \"launch\": {\"a\": true}}, \"config\": \"debug\", \"executable\": \"executable\"}, \"shared\": true, \"test_action\": {\"arguments\": {\"environment\": {\"a\": \"b\"}, \"launch\": {\"a\": true}}, \"config\": \"debug\", \"coverage\": true, \"targets\": [\"target\"], \"pre_actions\": [{\"title\": \"Run Script\", \"script_text\": \"echo test_action\", \"target\": \"target\"}], \"post_actions\": [{\"title\": \"Run Script\", \"script_text\": \"echo test_action\", \"target\": \"target\"}]}}"
let expected = "{\"build_action\": {\"targets\": [\"target\"], \"pre_actions\": [{\"title\": \"Run Script\", \"script_text\": \"echo build_action\", \"target\": \"target\"}], \"post_actions\": [{\"title\": \"Run Script\", \"script_text\": \"echo build_action\", \"target\": \"target\"}]}, \"name\": \"scheme\", \"run_action\": {\"arguments\": {\"environment\": {\"run\": \"b\"}, \"launch\": {\"run\": true}}, \"config\": \"debug\", \"executable\": \"executable\"}, \"shared\": true, \"test_action\": {\"arguments\": {\"environment\": {\"test\": \"b\"}, \"launch\": {\"test\": true}}, \"config\": \"debug\", \"coverage\": true, \"targets\": [\"target\"], \"pre_actions\": [{\"title\": \"Run Script\", \"script_text\": \"echo test_action\", \"target\": \"target\"}], \"post_actions\": [{\"title\": \"Run Script\", \"script_text\": \"echo test_action\", \"target\": \"target\"}]}}"
assertCodableEqualToJson(subject, expected)
}
}

View File

@ -86,7 +86,7 @@ final class SchemeGeneratorTests: XCTestCase {
let got = subject.schemeTestAction(scheme: scheme, project: project, generatedProject: generatedProject)
XCTAssertEqual(got?.buildConfiguration, "Debug")
XCTAssertEqual(got?.shouldUseLaunchSchemeArgsEnv, true)
XCTAssertEqual(got?.shouldUseLaunchSchemeArgsEnv, false)
XCTAssertNil(got?.macroExpansion)
XCTAssertEqual(got?.testables.count, 0)
}
@ -95,7 +95,8 @@ final class SchemeGeneratorTests: XCTestCase {
let target = Target.test(name: "App", product: .app)
let testTarget = Target.test(name: "AppTests", product: .unitTests)
let scheme = Scheme.test(name: "AppTests")
let testAction = TestAction.test(arguments: nil)
let scheme = Scheme.test(name: "AppTests", testAction: testAction)
let project = Project.test(targets: [target, testTarget])
let pbxTarget = PBXNativeTarget(name: "App")