diff --git a/README.md b/README.md index 284cd12d..980f4d11 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Run tests with custom xcconfig file path: | --- | --- | --- | --- | | `project_path` | Xcode Project (`.xcodeproj`) or Workspace (`.xcworkspace`) path. The input value sets xcodebuild's `-project` or `-workspace` option. If this is a Swift package, this should be the path to the `Package.swift` file. | required | `$BITRISE_PROJECT_PATH` | | `scheme` | Xcode Scheme name. The input value sets xcodebuild's `-scheme` option. | required | `$BITRISE_SCHEME` | -| `destination` | Destination specifier describes the device to use as a destination. The input value sets xcodebuild's `-destination` option. | required | `platform=iOS Simulator,name=iPhone 11,OS=latest` | +| `destination` | Destination specifier describes the device to use as a destination. The input value sets xcodebuild's `-destination` option. In a CI environment, a Simulator device called `Bitrise iOS default` is already created. It is a compatible device with the selected Simulator runtime, pre-warmed for better performance. If a device with this name is not found (e.g. in a local dev environment), the first matching device will be selected. | required | `platform=iOS Simulator,name=Bitrise iOS default,OS=latest` | | `test_plan` | Run tests in a specific Test Plan associated with the Scheme. Leave this input empty to run the default Test Plan or Test Targets associated with the Scheme. The input value sets xcodebuild's `-testPlan` option. | | | | `test_repetition_mode` | Determines how the tests will repeat. Available options: - `none`: Tests will never repeat. - `until_failure`: Tests will repeat until failure or up to maximum repetitions. - `retry_on_failure`: Only failed tests will repeat up to maximum repetitions. - `up_until_maximum_repetitions`: Tests will repeat up until maximum repetitions. The input value together with Maximum Test Repetitions (`maximum_test_repetitions`) input sets xcodebuild's `-run-tests-until-failure` / `-retry-tests-on-failure` or `-test-iterations` option. | | `none` | | `maximum_test_repetitions` | The maximum number of times a test repeats based on the Test Repetition Mode (`test_repetition_mode`). Should be more than 1 if the Test Repetition Mode is other than `none`. The input value sets xcodebuild's `-test-iterations` option. | required | `3` | @@ -105,10 +105,10 @@ Run tests with custom xcconfig file path: | `xcconfig_content` | Build settings to override the project's build settings, using xcodebuild's `-xcconfig` option. You can't define `-xcconfig` option in `Additional options for the xcodebuild command` if this input is set. If empty, no setting is changed. When set it can be either: 1. Existing `.xcconfig` file path. Example: `./ios-sample/ios-sample/Configurations/Dev.xcconfig` 2. The contents of a newly created temporary `.xcconfig` file. (This is the default.) Build settings must be separated by newline character (`\n`). Example: ``` COMPILER_INDEX_STORE_ENABLE = NO ONLY_ACTIVE_ARCH[config=Debug][sdk=*][arch=*] = YES ``` | | `COMPILER_INDEX_STORE_ENABLE = NO` | | `perform_clean_action` | If this input is set, `clean` xcodebuild action will be performed besides the `test` action. | required | `no` | | `xcodebuild_options` | Additional options to be added to the executed xcodebuild command. Prefer using `Build settings (xcconfig)` input for specifying `-xcconfig` option. You can't use both. | | | -| `log_formatter` | Defines how xcodebuild command's log is formatted. Available options: - `xcbeautify`: The xcodebuild command's output will be beautified by xcbeautify. - `xcodebuild`: Only the last 20 lines of raw xcodebuild output will be visible in the build log. - `xcpretty`: The xcodebuild command's output will be prettified by xcpretty. The raw xcodebuild log will be exported in all cases. | required | `xcpretty` | +| `log_formatter` | Defines how xcodebuild command's log is formatted. Available options: - `xcbeautify`: The xcodebuild command's output will be beautified by xcbeautify. - `xcodebuild`: Only the last 20 lines of raw xcodebuild output will be visible in the build log. - `xcpretty`: The xcodebuild command's output will be prettified by xcpretty. The raw xcodebuild log will be exported in all cases. | required | `xcbeautify` | | `xcbeautify_options` | Additional options to be added to the executed xcbeautify command. | | | | `xcpretty_options` | Additional options to be added to the executed xcpretty command. | | `--color --report html --output "${BITRISE_DEPLOY_DIR}/xcode-test-results-${BITRISE_SCHEME}.html"` | -| `cache_level` | Defines what cache content should be automatically collected. Available options: - `none`: Disable collecting cache content. - `swift_packages`: Collect Swift PM packages added to the Xcode project. | | `swift_packages` | +| `cache_level` | Defines what cache content should be automatically collected. Use key-based caching instead for better performance. Available options: - `none`: Disable collecting cache content. - `swift_packages`: Collect Swift PM packages added to the Xcode project. With key-based caching, you only need the Restore SPM cache and the Save SPM cache Steps to cache your Swift packages. [See devcenter for more information.](https://devcenter.bitrise.io/en/dependencies-and-caching/managing-dependencies-for-ios-apps/managing-dependencies-with-spm.html#caching-swift-packages) | | `none` | | `verbose_log` | If this input is set, the Step will print additional logs for debugging. | | `no` | | `collect_simulator_diagnostics` | If this input is set, the simulator verbose logging will be enabled and the simulator diagnostics log will be exported. | | `never` | | `headless_mode` | In headless mode the simulator is not launched in the foreground. If this input is set, the simulator will not be visible but tests (even the screenshots) will run just like if you run a simulator in foreground. | | `yes` | diff --git a/go.mod b/go.mod index a58c516b..eb7a73b8 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,7 @@ require ( github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.18 github.com/bitrise-io/go-utils v1.0.9 github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.19 - github.com/bitrise-io/go-xcode v1.0.13 - github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.29 + github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.30 github.com/hashicorp/go-version v1.6.0 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/stretchr/testify v1.8.4 @@ -28,5 +27,6 @@ require ( golang.org/x/sys v0.10.0 // indirect golang.org/x/term v0.10.0 // indirect golang.org/x/text v0.11.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 93820be6..216f1cac 100644 --- a/go.sum +++ b/go.sum @@ -2,54 +2,33 @@ github.com/bitrise-io/bitrise v0.0.0-20230707121919-a5b9e2d27ea9 h1:WMaMm6qwwEoA github.com/bitrise-io/bitrise v0.0.0-20230707121919-a5b9e2d27ea9/go.mod h1:WcWeEnuP6x54mUVw9L9pGUmllo67aqtXGr+pBIWv+4A= github.com/bitrise-io/envman v0.0.0-20230721122944-6b164ed0c2f8 h1:tBhRcS1lxkFrPpnYHbeeQE3DzEVEbs8CMs2y2ppVPB0= github.com/bitrise-io/envman v0.0.0-20230721122944-6b164ed0c2f8/go.mod h1:eZDEXpkF4BguvTERmhij3Vwf7Y2qvnJBBW/61hQRip4= -github.com/bitrise-io/go-plist v0.0.0-20210301100253-4b1a112ccd10/go.mod h1:pARutiL3kEuRLV3JvswidvfCj+9Y3qMZtji2BDqLFsA= -github.com/bitrise-io/go-steputils v1.0.1/go.mod h1:YIUaQnIAyK4pCvQG0hYHVkSzKNT9uL2FWmkFNW4mfNI= -github.com/bitrise-io/go-steputils v1.0.2/go.mod h1:YIUaQnIAyK4pCvQG0hYHVkSzKNT9uL2FWmkFNW4mfNI= github.com/bitrise-io/go-steputils v1.0.5 h1:OBH7CPXeqIWFWJw6BOUMQnUb8guspwKr2RhYBhM9tfc= github.com/bitrise-io/go-steputils v1.0.5/go.mod h1:YIUaQnIAyK4pCvQG0hYHVkSzKNT9uL2FWmkFNW4mfNI= -github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.2/go.mod h1:OC0mHpjD/bqmsHlhG+FWgTouBbcJvmyx896PDP3dRBs= github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.18 h1:43cs5DGgfTWEcaod3hZ7eqOQjhVnOL1QiY6TN3xDhhw= github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.18/go.mod h1:/ueNOKnsjcUrlt8Ck75WRNspL7E6nAAylvl9oGJtYio= github.com/bitrise-io/go-utils v1.0.1/go.mod h1:ZY1DI+fEpZuFpO9szgDeICM4QbqoWVt0RSY3tRI1heY= -github.com/bitrise-io/go-utils v1.0.2/go.mod h1:ZY1DI+fEpZuFpO9szgDeICM4QbqoWVt0RSY3tRI1heY= github.com/bitrise-io/go-utils v1.0.9 h1:wy7FewUpseNSTZr41BbGH0csfFqzptFt4zy2pOAEOg0= github.com/bitrise-io/go-utils v1.0.9/go.mod h1:ZY1DI+fEpZuFpO9szgDeICM4QbqoWVt0RSY3tRI1heY= -github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.1/go.mod h1:sy+Ir1X8P3tAAx/qU/r+hqDjHDcrMjIzDEvId1wqNc4= -github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.11/go.mod h1:SJqGxzwjIAx2LVQxNGS4taN7X//eDPJLrFxJ1MpOuyA= github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.19 h1:55as5Iv0N4btuRP3YwRzN+BCMtKO210MnJ8mpxmeI7o= github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.19/go.mod h1:Laih4ji980SQkRgdnMCH0g4u2GZI/5nnbqmYT9UfKFQ= -github.com/bitrise-io/go-xcode v1.0.9/go.mod h1:Y0Wu2dXm0MilJ/4D3+gPHaNMlUcP+1DjIPoLPykq7wY= -github.com/bitrise-io/go-xcode v1.0.13 h1:XBJqZnDswCIVtpFKxJKG2cAQ3ETpOMHBrlKLQSJp6GI= -github.com/bitrise-io/go-xcode v1.0.13/go.mod h1:Y0Wu2dXm0MilJ/4D3+gPHaNMlUcP+1DjIPoLPykq7wY= -github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.29 h1:2zkc0zoCyAczFX/zkmrEgF+KVpsytANZpy2o4MAQnas= -github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.29/go.mod h1:8WBcRgrVXY8tzR7NcjE4fw6WguOIfB3YcC7ZTcQYUEY= -github.com/bitrise-io/pkcs12 v0.0.0-20211108084543-e52728e011c8/go.mod h1:UiXKNs0essbC14a2TvGlnUKo9isP9m4guPrp8KJHJpU= +github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.30 h1:jPH59NEhvEQUSuSZfHBB+entqgp3h7fzCEc8aixcVOM= +github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.30/go.mod h1:AAbNlJZIhJHanj7H90R7Qr2K/Ux0DTYVhSaySqYG2nY= github.com/bitrise-io/stepman v0.0.0-20230728094915-939f0fe5c19a h1:XM2PrNSUjpI4pIOZ1TcZdD4kh7KYN2D+yC6WYy22hoo= github.com/bitrise-io/stepman v0.0.0-20230728094915-939f0fe5c19a/go.mod h1:Z46oQnRMHlbuiV0mCJBigT2bWO5j3TPQncKaL3jCwsk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA= -github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-retryablehttp v0.7.0/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= -github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA= github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= -github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= @@ -57,8 +36,6 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= @@ -83,7 +60,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -91,20 +67,15 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= diff --git a/main.go b/main.go index dcac4aaa..e16e8778 100644 --- a/main.go +++ b/main.go @@ -18,12 +18,12 @@ import ( "github.com/bitrise-io/go-xcode/v2/simulator" "github.com/bitrise-io/go-xcode/v2/xcconfig" cache "github.com/bitrise-io/go-xcode/v2/xcodecache" + "github.com/bitrise-io/go-xcode/v2/xcodecommand" "github.com/bitrise-io/go-xcode/v2/xcodeversion" "github.com/bitrise-steplib/steps-xcode-test/output" "github.com/bitrise-steplib/steps-xcode-test/step" "github.com/bitrise-steplib/steps-xcode-test/testaddon" "github.com/bitrise-steplib/steps-xcode-test/xcodebuild" - "github.com/bitrise-steplib/steps-xcode-test/xcodecommand" ) func main() { diff --git a/mocks/Runner.go b/mocks/Runner.go index 6f248e53..a716f1b9 100644 --- a/mocks/Runner.go +++ b/mocks/Runner.go @@ -6,7 +6,7 @@ import ( version "github.com/hashicorp/go-version" mock "github.com/stretchr/testify/mock" - xcodecommand "github.com/bitrise-steplib/steps-xcode-test/xcodecommand" + xcodecommand "github.com/bitrise-io/go-xcode/v2/xcodecommand" ) // XcodeCommandRunner is an autogenerated mock type for the Runner type diff --git a/step.yml b/step.yml index 69ac531b..de736c9e 100644 --- a/step.yml +++ b/step.yml @@ -62,7 +62,7 @@ inputs: The input value sets xcodebuild's `-scheme` option. is_required: true -- destination: platform=iOS Simulator,name=iPhone 8 Plus,OS=latest +- destination: platform=iOS Simulator,name=Bitrise iOS default,OS=latest opts: title: Device destination specifier summary: Destination specifier describes the device to use as a destination. @@ -70,6 +70,11 @@ inputs: Destination specifier describes the device to use as a destination. The input value sets xcodebuild's `-destination` option. + + In a CI environment, a Simulator device called `Bitrise iOS default` is already created. + It is a compatible device with the selected Simulator runtime, pre-warmed for better performance. + + If a device with this name is not found (e.g. in a local dev environment), the first matching device will be selected. is_required: true - test_plan: @@ -201,7 +206,7 @@ inputs: # xcodebuild log formatting -- log_formatter: xcpretty +- log_formatter: xcbeautify opts: category: xcodebuild log formatting title: Log formatter @@ -235,17 +240,20 @@ inputs: # Caching -- cache_level: swift_packages +- cache_level: none opts: - category: Caching + category: Branch-based (legacy) caching title: Enable collecting cache content - summary: Defines what cache content should be automatically collected. + summary: Defines what cache content should be automatically collected. Use key-based caching instead for better performance. description: |- - Defines what cache content should be automatically collected. + Defines what cache content should be automatically collected. Use key-based caching instead for better performance. Available options: - `none`: Disable collecting cache content. - `swift_packages`: Collect Swift PM packages added to the Xcode project. + + With key-based caching, you only need the Restore SPM cache and the Save SPM cache Steps to cache your Swift packages. + [See devcenter for more information.](https://devcenter.bitrise.io/en/dependencies-and-caching/managing-dependencies-for-ios-apps/managing-dependencies-with-spm.html#caching-swift-packages) value_options: - none - swift_packages diff --git a/step/mocks/Xcodebuild.go b/step/mocks/Xcodebuild.go index e5b5852a..bbfbdb13 100644 --- a/step/mocks/Xcodebuild.go +++ b/step/mocks/Xcodebuild.go @@ -4,7 +4,7 @@ package mocks import ( xcodebuild "github.com/bitrise-steplib/steps-xcode-test/xcodebuild" - xcodecommand "github.com/bitrise-steplib/steps-xcode-test/xcodecommand" + xcodecommand "github.com/bitrise-io/go-xcode/v2/xcodecommand" mock "github.com/stretchr/testify/mock" ) diff --git a/step/step.go b/step/step.go index 78ad98b0..13e3d66f 100644 --- a/step/step.go +++ b/step/step.go @@ -17,10 +17,10 @@ import ( "github.com/bitrise-io/go-xcode/v2/destination" "github.com/bitrise-io/go-xcode/v2/simulator" cache "github.com/bitrise-io/go-xcode/v2/xcodecache" + "github.com/bitrise-io/go-xcode/v2/xcodecommand" "github.com/bitrise-io/go-xcode/v2/xcodeversion" "github.com/bitrise-steplib/steps-xcode-test/output" "github.com/bitrise-steplib/steps-xcode-test/xcodebuild" - "github.com/bitrise-steplib/steps-xcode-test/xcodecommand" "github.com/kballard/go-shellquote" ) @@ -374,17 +374,14 @@ func (s XcodeTestConfigParser) getSimulatorForDestination(destinationSpecifier s if err != nil { return destination.Device{}, fmt.Errorf("invalid destination specifier (%s): %w", destinationSpecifier, err) } - if simulatorDestination == nil { - return destination.Device{}, fmt.Errorf("inconsistent state, destination should not be nil") - } device, err := s.deviceFinder.FindDevice(*simulatorDestination) if err != nil { return destination.Device{}, fmt.Errorf("simulator UDID lookup failed: %w", err) } - s.logger.Infof("Simulator info") - s.logger.Printf("* simulator_name: %s, version: %s, UDID: %s, status: %s", device.Name, device.OS, device.ID, device.Status) + s.logger.Infof("Destination simulator:") + s.logger.Printf("* Name: %s, type: %s, version: %s, UDID: %s, status: %s", device.Name, device.Type, device.OS, device.ID, device.Status) return device, nil } diff --git a/vendor/github.com/bitrise-io/go-xcode/LICENSE b/vendor/github.com/bitrise-io/go-xcode/LICENSE deleted file mode 100644 index cdfcf1f7..00000000 --- a/vendor/github.com/bitrise-io/go-xcode/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Bitrise - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/bitrise-io/go-xcode/models/models.go b/vendor/github.com/bitrise-io/go-xcode/models/models.go deleted file mode 100644 index 42ea3721..00000000 --- a/vendor/github.com/bitrise-io/go-xcode/models/models.go +++ /dev/null @@ -1,8 +0,0 @@ -package models - -// XcodebuildVersionModel ... -type XcodebuildVersionModel struct { - Version string - BuildVersion string - MajorVersion int64 -} diff --git a/vendor/github.com/bitrise-io/go-xcode/utility/path.go b/vendor/github.com/bitrise-io/go-xcode/utility/path.go deleted file mode 100644 index 99db9138..00000000 --- a/vendor/github.com/bitrise-io/go-xcode/utility/path.go +++ /dev/null @@ -1,39 +0,0 @@ -package utility - -import ( - "fmt" - "path/filepath" - - "github.com/bitrise-io/go-utils/pathutil" -) - -// FindFileInAppDir ... -func FindFileInAppDir(appDir, fileName string) (string, error) { - filePth := filepath.Join(appDir, fileName) - if exist, err := pathutil.IsPathExists(filePth); err != nil { - return "", err - } else if exist { - return filePth, nil - } - // --- - - // It's somewhere else - let's find it! - apps, err := pathutil.ListEntries(appDir, pathutil.ExtensionFilter(".app", true)) - if err != nil { - return "", err - } - - for _, app := range apps { - pths, err := pathutil.ListEntries(app, pathutil.BaseFilter(fileName, true)) - if err != nil { - return "", err - } - - if len(pths) > 0 { - return pths[0], nil - } - } - // --- - - return "", fmt.Errorf("failed to find %s", fileName) -} diff --git a/vendor/github.com/bitrise-io/go-xcode/utility/utility.go b/vendor/github.com/bitrise-io/go-xcode/utility/utility.go deleted file mode 100644 index 8d942de7..00000000 --- a/vendor/github.com/bitrise-io/go-xcode/utility/utility.go +++ /dev/null @@ -1,72 +0,0 @@ -package utility - -import ( - "fmt" - "strconv" - "strings" - - "github.com/bitrise-io/go-utils/command" - "github.com/bitrise-io/go-xcode/models" -) - -// GetXcodeVersion ... -func GetXcodeVersion() (models.XcodebuildVersionModel, error) { - cmd := command.New("xcodebuild", "-version") - outStr, err := cmd.RunAndReturnTrimmedCombinedOutput() - if err != nil { - return models.XcodebuildVersionModel{}, fmt.Errorf("xcodebuild -version failed, err: %s, details: %s", err, outStr) - } - return getXcodeVersionFromXcodebuildOutput(outStr) -} - -func getXcodeVersionFromXcodebuildOutput(outStr string) (models.XcodebuildVersionModel, error) { - split := strings.Split(outStr, "\n") - if len(split) == 0 { - return models.XcodebuildVersionModel{}, fmt.Errorf("failed to parse xcodebuild version output (%s)", outStr) - } - - filteredOutput, err := filterXcodeWarnings(split) - if err != nil { - return models.XcodebuildVersionModel{}, err - } - - xcodebuildVersion := filteredOutput[0] - buildVersion := filteredOutput[1] - - split = strings.Split(xcodebuildVersion, " ") - if len(split) != 2 { - return models.XcodebuildVersionModel{}, fmt.Errorf("failed to parse xcodebuild version output (%s)", outStr) - } - - version := split[1] - - split = strings.Split(version, ".") - majorVersionStr := split[0] - - majorVersion, err := strconv.ParseInt(majorVersionStr, 10, 32) - if err != nil { - return models.XcodebuildVersionModel{}, fmt.Errorf("failed to parse xcodebuild version output (%s), error: %s", outStr, err) - } - - return models.XcodebuildVersionModel{ - Version: xcodebuildVersion, - BuildVersion: buildVersion, - MajorVersion: majorVersion, - }, nil -} - -func filterXcodeWarnings(cmdOutputLines []string) ([]string, error) { - firstLineIndex := -1 - for i, line := range cmdOutputLines { - if strings.HasPrefix(line, "Xcode ") { - firstLineIndex = i - break - } - } - - if firstLineIndex < 0 { - return []string{}, fmt.Errorf("couldn't find Xcode version in output: %s", cmdOutputLines) - } - - return cmdOutputLines[firstLineIndex:], nil -} diff --git a/vendor/github.com/bitrise-io/go-xcode/v2/destination/device_finder.go b/vendor/github.com/bitrise-io/go-xcode/v2/destination/device_finder.go index fdf0516e..d478598b 100644 --- a/vendor/github.com/bitrise-io/go-xcode/v2/destination/device_finder.go +++ b/vendor/github.com/bitrise-io/go-xcode/v2/destination/device_finder.go @@ -17,6 +17,7 @@ const defaultDeviceName = "Bitrise iOS default" type Device struct { ID string Status string + Type string Platform string Name string diff --git a/vendor/github.com/bitrise-io/go-xcode/v2/destination/parse.go b/vendor/github.com/bitrise-io/go-xcode/v2/destination/parse.go index 57f5738a..3520fc96 100644 --- a/vendor/github.com/bitrise-io/go-xcode/v2/destination/parse.go +++ b/vendor/github.com/bitrise-io/go-xcode/v2/destination/parse.go @@ -208,6 +208,7 @@ func (d deviceFinder) filterDeviceList(wantedDevice Simulator) (Device, error) { return Device{ ID: device.UDID, Status: device.State, + Type: d.convertDeviceTypeIDToDeviceName(device.TypeIdentifier), Platform: wantedPlatform, Name: device.Name, OS: runtime.Version, @@ -226,6 +227,7 @@ func (d deviceFinder) filterDeviceList(wantedDevice Simulator) (Device, error) { return Device{ ID: device.UDID, Status: device.State, + Type: d.convertDeviceTypeIDToDeviceName(device.TypeIdentifier), Platform: wantedPlatform, Name: device.Name, OS: runtime.Version, @@ -235,19 +237,19 @@ func (d deviceFinder) filterDeviceList(wantedDevice Simulator) (Device, error) { } // If there is no matching device, look up device type so we can create device in a later step - deviceTypeIdentifier, err := d.lookupDeviceTypeID(wantedDevice.Name) + deviceTypeID, err := d.convertDeviceNameToDeviceTypeID(wantedDevice.Name) if err != nil { return Device{}, err } - if !runtime.isDeviceSupported(deviceTypeIdentifier) { - return Device{}, fmt.Errorf("runtime (%s) is incompatible with device type (%s)", runtimeID, deviceTypeIdentifier) + if !runtime.isDeviceSupported(deviceTypeID) { + return Device{}, fmt.Errorf("runtime (%s) is incompatible with device type (%s)", runtimeID, deviceTypeID) } - return Device{}, newMissingDeviceErr(wantedDevice.Name, deviceTypeIdentifier, runtimeID) + return Device{}, newMissingDeviceErr(wantedDevice.Name, deviceTypeID, runtimeID) } -func (d deviceFinder) lookupDeviceTypeID(wantedDeviceName string) (string, error) { +func (d deviceFinder) convertDeviceNameToDeviceTypeID(wantedDeviceName string) (string, error) { for _, dt := range d.list.DeviceTypes { if dt.Name == wantedDeviceName { return dt.Identifier, nil @@ -257,6 +259,19 @@ func (d deviceFinder) lookupDeviceTypeID(wantedDeviceName string) (string, error return "", fmt.Errorf("invalid device name (%s) provided", wantedDeviceName) } +// convertDeviceTypeIDToDeviceName returns the device type (e.g. iPhone 11) for logging purposes. +// The device name equals this by default, but not for all manually created devices like `Bitrise iOS default` +func (d deviceFinder) convertDeviceTypeIDToDeviceName(wantedDeviceTypeID string) string { + for _, dt := range d.list.DeviceTypes { + if dt.Identifier == wantedDeviceTypeID { + return dt.Name + } + } + + // Should not happen. Falling back to the device type ID, as used for logging only. + return wantedDeviceTypeID +} + func isEqualVersion(wantVersion *version.Version, runtimeVersion *version.Version) bool { wantVersionSegments := wantVersion.Segments() runtimeVersionSegments := runtimeVersion.Segments() diff --git a/xcodecommand/mock_xcprettyManager.go b/vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/mock_xcprettyManager.go similarity index 100% rename from xcodecommand/mock_xcprettyManager.go rename to vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/mock_xcprettyManager.go diff --git a/xcodecommand/xcbeautify.go b/vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcbeautify.go similarity index 82% rename from xcodecommand/xcbeautify.go rename to vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcbeautify.go index 4fa9a77d..4a4c21e0 100644 --- a/xcodecommand/xcbeautify.go +++ b/vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcbeautify.go @@ -8,7 +8,6 @@ import ( "os" "os/exec" - "github.com/bitrise-io/go-utils/errorutil" "github.com/bitrise-io/go-utils/v2/command" "github.com/bitrise-io/go-utils/v2/log" "github.com/bitrise-io/go-xcode/v2/errorfinder" @@ -17,19 +16,22 @@ import ( const xcbeautify = "xcbeautify" -type xcbeautifyRunner struct { +// XcbeautifyRunner is a xcodebuild runner that uses xcbeautify as log formatter +type XcbeautifyRunner struct { logger log.Logger commandFactory command.Factory } +// NewXcbeautifyRunner returns a new xcbeautify runner func NewXcbeautifyRunner(logger log.Logger, commandFactory command.Factory) Runner { - return &xcbeautifyRunner{ + return &XcbeautifyRunner{ logger: logger, commandFactory: commandFactory, } } -func (c *xcbeautifyRunner) Run(workDir string, xcodebuildArgs []string, xcbeautifyArgs []string) (Output, error) { +// Run runs xcodebuild using xcbeautify as an output formatter +func (c *XcbeautifyRunner) Run(workDir string, xcodebuildArgs []string, xcbeautifyArgs []string) (Output, error) { var ( buildOutBuffer bytes.Buffer pipeReader, pipeWriter = io.Pipe() @@ -88,7 +90,8 @@ func (c *xcbeautifyRunner) Run(workDir string, xcodebuildArgs []string, xcbeauti }, err } -func (c *xcbeautifyRunner) CheckInstall() (*version.Version, error) { +// CheckInstall checks if xcbeautify is on the PATH and returns its version +func (c *XcbeautifyRunner) CheckInstall() (*version.Version, error) { c.logger.Println() c.logger.Infof("Checking log formatter (xcbeautify) version") @@ -96,7 +99,8 @@ func (c *xcbeautifyRunner) CheckInstall() (*version.Version, error) { out, err := versionCmd.RunAndReturnTrimmedOutput() if err != nil { - if errorutil.IsExitStatusError(err) { + var exerr *exec.ExitError + if errors.As(err, &exerr) { return nil, fmt.Errorf("xcbeautify version command failed: %w", err) } diff --git a/xcodecommand/xcodebuild_only.go b/vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcodebuild_only.go similarity index 68% rename from xcodecommand/xcodebuild_only.go rename to vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcodebuild_only.go index aab2e776..efd0e269 100644 --- a/xcodecommand/xcodebuild_only.go +++ b/vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcodebuild_only.go @@ -13,19 +13,22 @@ import ( var xcodeCommandEnvs = []string{"NSUnbufferedIO=YES"} -type rawXcodeCommand struct { +// RawXcodeCommandRunner is an xcodebuild runner that uses no additional log formatter +type RawXcodeCommandRunner struct { logger log.Logger commandFactory command.Factory } +// NewRawCommandRunner creates a new RawXcodeCommandRunner func NewRawCommandRunner(logger log.Logger, commandFactory command.Factory) Runner { - return &rawXcodeCommand{ + return &RawXcodeCommandRunner{ logger: logger, commandFactory: commandFactory, } } -func (c *rawXcodeCommand) Run(workDir string, args []string, _ []string) (Output, error) { +// Run runs xcodebuild using no additional log formatter +func (c *RawXcodeCommandRunner) Run(workDir string, args []string, _ []string) (Output, error) { var ( outBuffer bytes.Buffer err error @@ -52,6 +55,7 @@ func (c *rawXcodeCommand) Run(workDir string, args []string, _ []string) (Output }, err } -func (c *rawXcodeCommand) CheckInstall() (*version.Version, error) { +// CheckInstall does nothing as no additional log formatter is used +func (c *RawXcodeCommandRunner) CheckInstall() (*version.Version, error) { return nil, nil } diff --git a/xcodecommand/xcodecommand.go b/vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcodecommand.go similarity index 63% rename from xcodecommand/xcodecommand.go rename to vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcodecommand.go index 912d4232..5928cb8a 100644 --- a/xcodecommand/xcodecommand.go +++ b/vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcodecommand.go @@ -4,11 +4,13 @@ import ( "github.com/hashicorp/go-version" ) +// Output is the direct output of the xcodebuild command, unchanged by log formatters type Output struct { RawOut []byte ExitCode int } +// Runner abstarcts an xcodebuild command runner, it can use any log formatter type Runner interface { CheckInstall() (*version.Version, error) Run(workDir string, xcodebuildOpts []string, logFormatterOpts []string) (Output, error) diff --git a/xcodecommand/xcpretty.go b/vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcpretty.go similarity index 89% rename from xcodecommand/xcpretty.go rename to vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcpretty.go index 45af97be..0a6aae4d 100644 --- a/xcodecommand/xcpretty.go +++ b/vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcpretty.go @@ -15,7 +15,8 @@ import ( "github.com/bitrise-io/go-xcode/v2/errorfinder" ) -type xcprettyCommandRunner struct { +// XcprettyCommandRunner is an xcodebuild command runner that uses xcpretty as log formatter +type XcprettyCommandRunner struct { logger log.Logger commandFactory command.Factory pathChecker pathutil.PathChecker @@ -23,8 +24,9 @@ type xcprettyCommandRunner struct { xcpretty xcprettyManager // used by CheckInstall } +// NewXcprettyCommandRunner crates a new XcprettyCommandRunner func NewXcprettyCommandRunner(logger log.Logger, commandFactory command.Factory, pathChecker pathutil.PathChecker, fileManager fileutil.FileManager, rubyCommandFactory ruby.CommandFactory, rubyEnv ruby.Environment) Runner { - return &xcprettyCommandRunner{ + return &XcprettyCommandRunner{ logger: logger, commandFactory: commandFactory, pathChecker: pathChecker, @@ -37,7 +39,8 @@ func NewXcprettyCommandRunner(logger log.Logger, commandFactory command.Factory, } } -func (c *xcprettyCommandRunner) Run(workDir string, xcodebuildArgs []string, xcprettyArgs []string) (Output, error) { +// Run runs xcodebuild using xcpretty as a log formatter +func (c *XcprettyCommandRunner) Run(workDir string, xcodebuildArgs []string, xcprettyArgs []string) (Output, error) { var ( buildOutBuffer bytes.Buffer pipeReader, pipeWriter = io.Pipe() @@ -98,7 +101,7 @@ func (c *xcprettyCommandRunner) Run(workDir string, xcodebuildArgs []string, xcp }, err } -func (c *xcprettyCommandRunner) cleanOutputFile(xcprettyArgs []string) { +func (c *XcprettyCommandRunner) cleanOutputFile(xcprettyArgs []string) { // get and delete the xcpretty output file, if exists xcprettyOutputFilePath := "" isNextOptOutputPth := false diff --git a/xcodecommand/xcpretty_installer.go b/vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcpretty_installer.go similarity index 91% rename from xcodecommand/xcpretty_installer.go rename to vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcpretty_installer.go index f0349cca..bf2d8272 100644 --- a/xcodecommand/xcpretty_installer.go +++ b/vendor/github.com/bitrise-io/go-xcode/v2/xcodecommand/xcpretty_installer.go @@ -20,7 +20,9 @@ type xcpretty struct { rubyCommandFactory ruby.CommandFactory } -func (c *xcprettyCommandRunner) CheckInstall() (*version.Version, error) { +// CheckInstall checks if xcpretty is isntalled, if not installs it. +// Returns its version. +func (c *XcprettyCommandRunner) CheckInstall() (*version.Version, error) { c.logger.Println() c.logger.Infof("Checking if log formatter (xcpretty) is installed") diff --git a/vendor/modules.txt b/vendor/modules.txt index 4d6e61e7..fdaf2b7b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -44,17 +44,14 @@ github.com/bitrise-io/go-utils/v2/fileutil github.com/bitrise-io/go-utils/v2/log github.com/bitrise-io/go-utils/v2/log/colorstring github.com/bitrise-io/go-utils/v2/pathutil -# github.com/bitrise-io/go-xcode v1.0.13 -## explicit; go 1.15 -github.com/bitrise-io/go-xcode/models -github.com/bitrise-io/go-xcode/utility -# github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.29 -## explicit; go 1.16 +# github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.30 +## explicit; go 1.18 github.com/bitrise-io/go-xcode/v2/destination github.com/bitrise-io/go-xcode/v2/errorfinder github.com/bitrise-io/go-xcode/v2/simulator github.com/bitrise-io/go-xcode/v2/xcconfig github.com/bitrise-io/go-xcode/v2/xcodecache +github.com/bitrise-io/go-xcode/v2/xcodecommand github.com/bitrise-io/go-xcode/v2/xcodeversion # github.com/bitrise-io/stepman v0.0.0-20230728094915-939f0fe5c19a ## explicit; go 1.18 @@ -104,6 +101,8 @@ golang.org/x/term ## explicit; go 1.17 golang.org/x/text/transform golang.org/x/text/unicode/norm +# gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c +## explicit; go 1.11 # gopkg.in/yaml.v3 v3.0.1 ## explicit gopkg.in/yaml.v3 diff --git a/xcodebuild/xcodebuild.go b/xcodebuild/xcodebuild.go index 211ee45e..cf73c1d4 100644 --- a/xcodebuild/xcodebuild.go +++ b/xcodebuild/xcodebuild.go @@ -4,7 +4,7 @@ import ( "github.com/bitrise-io/go-utils/v2/fileutil" "github.com/bitrise-io/go-utils/v2/log" "github.com/bitrise-io/go-xcode/v2/xcconfig" - "github.com/bitrise-steplib/steps-xcode-test/xcodecommand" + "github.com/bitrise-io/go-xcode/v2/xcodecommand" ) // Test repetition modes ... diff --git a/xcodebuild/xcodebuild_test.go b/xcodebuild/xcodebuild_test.go index 42f727cd..d9c5a573 100644 --- a/xcodebuild/xcodebuild_test.go +++ b/xcodebuild/xcodebuild_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/bitrise-io/go-utils/v2/log" + "github.com/bitrise-io/go-xcode/v2/xcodecommand" commonMocks "github.com/bitrise-steplib/steps-xcode-test/mocks" "github.com/bitrise-steplib/steps-xcode-test/xcodebuild/mocks" - "github.com/bitrise-steplib/steps-xcode-test/xcodecommand" "github.com/stretchr/testify/mock" ) diff --git a/xcodecommand/mocks/Command.go b/xcodecommand/mocks/Command.go deleted file mode 100644 index 11b9a653..00000000 --- a/xcodecommand/mocks/Command.go +++ /dev/null @@ -1,152 +0,0 @@ -// Code generated by mockery v2.30.16. DO NOT EDIT. - -package mocks - -import mock "github.com/stretchr/testify/mock" - -// Command is an autogenerated mock type for the Command type -type Command struct { - mock.Mock -} - -// PrintableCommandArgs provides a mock function with given fields: -func (_m *Command) PrintableCommandArgs() string { - ret := _m.Called() - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// Run provides a mock function with given fields: -func (_m *Command) Run() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// RunAndReturnExitCode provides a mock function with given fields: -func (_m *Command) RunAndReturnExitCode() (int, error) { - ret := _m.Called() - - var r0 int - var r1 error - if rf, ok := ret.Get(0).(func() (int, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() int); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(int) - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// RunAndReturnTrimmedCombinedOutput provides a mock function with given fields: -func (_m *Command) RunAndReturnTrimmedCombinedOutput() (string, error) { - ret := _m.Called() - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func() (string, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// RunAndReturnTrimmedOutput provides a mock function with given fields: -func (_m *Command) RunAndReturnTrimmedOutput() (string, error) { - ret := _m.Called() - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func() (string, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Start provides a mock function with given fields: -func (_m *Command) Start() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Wait provides a mock function with given fields: -func (_m *Command) Wait() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// NewCommand creates a new instance of Command. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewCommand(t interface { - mock.TestingT - Cleanup(func()) -}) *Command { - mock := &Command{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/xcodecommand/xcpretty_test.go b/xcodecommand/xcpretty_test.go deleted file mode 100644 index cef65f08..00000000 --- a/xcodecommand/xcpretty_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package xcodecommand - -import ( - "testing" - - gocommand "github.com/bitrise-io/go-utils/v2/command" - "github.com/bitrise-io/go-utils/v2/log" - mockcommand "github.com/bitrise-steplib/steps-xcode-test/xcodecommand/mocks" - "github.com/hashicorp/go-version" - "github.com/stretchr/testify/assert" -) - -type testingMocks struct { - command *mockcommand.Command - xcpretty *mockXcprettyManager -} - -func Test_GivenNotInstalled_WhenInstall_ThenInstallsIt(t *testing.T) { - // Given - installer, version, mocks := createInstallerAndMocks(t, false) - - // When - installedVersion, err := installer.CheckInstall() - - // Then - assert.NoError(t, err) - assert.Equal(t, version, installedVersion) - mocks.xcpretty.AssertCalled(t, "isDepInstalled") - mocks.xcpretty.AssertCalled(t, "installDep") - mocks.xcpretty.AssertCalled(t, "depVersion") - mocks.command.AssertCalled(t, "Run") -} - -func Test_GivenInstalled_WhenInstall_OnlyReturnsVersion(t *testing.T) { - // Given - installer, version, mocks := createInstallerAndMocks(t, true) - - // When - installedVersion, err := installer.CheckInstall() - - // Then - assert.NoError(t, err) - assert.Equal(t, version, installedVersion) - mocks.xcpretty.AssertCalled(t, "isDepInstalled") - mocks.xcpretty.AssertNotCalled(t, "installDep") - mocks.xcpretty.AssertCalled(t, "depVersion") - mocks.command.AssertNotCalled(t, "Run") -} - -func createInstallerAndMocks(t *testing.T, installed bool) (Runner, *version.Version, testingMocks) { - command := new(mockcommand.Command) - command.On("Run").Return(nil) - - version, _ := version.NewVersion("1.0.0") - - mockxcpretty := newMockXcprettyManager(t) - mockxcpretty.On("isDepInstalled").Return(installed, nil) - if !installed { - mockxcpretty.On("installDep").Return([]gocommand.Command{command}, nil) - } - mockxcpretty.On("depVersion").Return(version, nil) - - installer := &xcprettyCommandRunner{ - logger: log.NewLogger(), - xcpretty: mockxcpretty, - } - - return installer, version, testingMocks{ - command: command, - xcpretty: mockxcpretty, - } -}