<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 5, 2016, at 2:58 PM, Max Howell &lt;<a href="mailto:max.howell@apple.com" class="">max.howell@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Overall, I think the feature is important to have, but I don’t understand some of the aspects of the proposal. I also don’t think there is a real focus for clarity on the types of testing that are being supported here. The implication is that unit tests are what this is being targeted, but is this proposal specifically limiting to those particular types of tests? If so, why? If not, some of the aspects really don’t make much sense to be defaulted into.</div></div></div></blockquote><div class=""><br class=""></div>The proposal does not advocate any particular testing methodology. Certainly to start with we only support XCTest, but that is just a practical decision. Fundamentally the proposal is only advocating building modules that are *for* testing, and then executing these tests with a runner, which at first will be an XCTest runner.<br class=""></div></div></div></blockquote><div><br class=""></div><div>XCTest is just the runner with an additional style of how to validate the test. I’m talking about the distinction between unit, integration, performance, etc. All of these types of tests can be written with XCTest, though some harder than others. There are choices being made with the implicit assumption that tests in your test modules are unit tests. Running tests by default and only running tests by default on debug builds are examples of those implicit assumptions about the classification of test within your modules.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""></div><blockquote type="cite" class=""><div class="">Additionally we will support directories called&nbsp;FooTests. This layout style is prevalent in existing open source projects&nbsp;and supporting it will minimize vexation for their authors. However in the interest of consistency and the&nbsp;corresponding reduction of cognitive-load when examining new Swift packages we will not <span class="Apple-tab-span" style="white-space:pre">        </span>recommend this layout.&nbsp;For example:</div></blockquote><blockquote type="cite" class=""><br class=""></blockquote><div class=""></div><blockquote type="cite" class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp; Package</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; └── Sources</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; │ &nbsp; └── Foo.swift</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; └── FooTests</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; └── Test.swift</font></div></blockquote><div class=""><br class=""></div><div class="">Why support something that that is not going to be recommended? Prevalence of something seems like a poor choice, especially when you are going to specifically <i class="">not </i>recommend&nbsp;to use it. Also, the proposal already mentioned an override mechanism to allow these to be specified. This seems like something that could easily be cut.</div></div></div></blockquote><div class=""><br class=""></div>If we don’t cater to the thousands of projects already out there we potentially will hinder adoption.</div><div class=""><br class=""></div><div class="">I’d agree with you if supporting this was going to hurt, but it won’t.<br class=""></div></div></div></blockquote><div><br class=""></div><div>It “hurts” by increasing cost, maintenance, and cognitive overload for understanding all of the “out-of-the-box” ways that test modules get implicitly created.&nbsp;</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""></div><blockquote type="cite" class=""><div class="">Additionally, we propose that building a module also builds that module's corresponding tests. Although this would&nbsp;result in slightly increased build times, we believe that tests are important enough to justify this (one might even&nbsp;consider slow building tests to be a code smell). We would prefer to go even further by executing the tests each time&nbsp;a module is built as well, but we understand that this would impede debug cycles.</div></blockquote><div class=""><br class=""></div><div class="">Re-building tests all of the time is a huge time waste. Executing those tests even more so (also see original question on the types of tests being supported). Not only that, in production software, it’s very often the case that there are levels of tests that get run because of the shear amount of them that exist and the time involved to run them. In addition to levels, there are classifications of tests (perf, robustness, memory, stress, fuzzing, etc…).</div></div></div></blockquote><div class=""><br class=""></div><div class="">I would like to wait and see. If you are right and it is a huge time waste then we can turn this off.</div></div></div></div></blockquote><div><br class=""></div><div>Then please provide and specify how this can be opt-ed out of clearly. Is it the --without-tests flag? Can we specific default options in the Package.swift so that this always occurs?</div><div><br class=""></div><div>As a simple query, go around Apple and ask the compiler team if they want this feature for their code. Ask those developing in the corelibs. Ask any of the app teams. Please also do performance testing on this for various sized projects. It will absolutely have an impact, especially with regards to the current state of Swift compile times.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">This is something that should be an opt-in. The most basic example of this is refactoring a code base (which is later briefly mentioned at the end o the proposal). The first step is getting the code compiling for the project. It’s not true that the very next step you take is fix up the tests, especially in the cases that the refactoring/changes are exploratory.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Indeed, I agree. But I’d like to wait and see.</div></div></div></div></blockquote><div><br class=""></div><div>I really would like to understand what your metrics of acceptability are here. Is twice the build cost ok? Three times?</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class="">In the future, we may choose to promote the&nbsp;--test&nbsp;option to be a subcommand of the&nbsp;swift&nbsp;command itself:<br class=""><br class=""><div class=""><font face="Menlo" class="">$ swift test</font></div><br class="Apple-interchange-newline">However, any such decision would warrant extensive design consideration, so as to avoid polluting or crowding the&nbsp;command-line interface. Should there be sufficient demand and justification for it, though, it would be straightforward&nbsp;to add this functionality.</blockquote></div><div class=""><br class=""></div><div class="">This doesn’t make sense to me. It’s either straightforward, or it requires extensive design consideration. I personally strongly dislike coupling the notion of building with test execution, so I would much rather see “swift test” used, especially with a look into the future where it’s going to be asked for the ability to run categories of tests and filter to a particular set of tests to be run.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I agree, but my issue with `swift test` is that we are beginning to tightly couple `swift build` with swift itself. I’m not sure we should run-and-gun into this decision. SwiftPM is strictly alpha/beta and any decisions we make on these sorts of issues can change.</div></div></div></div></blockquote><div><br class=""></div><div>The alternatives are:</div><div><br class=""></div><div>1. Factor out to a new binary, like spm, or</div><div>2. Continue down the path of tightly coupling build code with test execution.</div><div><br class=""></div><div>I’d actually like to see the Swift Package Manager factor out to it’s own entity sooner rather than later and instead shell out and use the swift compiler. This would also help with other proposals, such as the “Getting C code compiling” one. But that’s a different proposal...</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Another real problem with this type of design, is that is makes more advanced build systems very complicated to make. For example, distributed builds that bring together all of the compiled bits to run tests on get blocked because the build command starts to expect certain intermediate output. This is a <i class="">real</i>&nbsp;problem my previous team still has to this day with xcodebuild and actively prevents us from doing this exact thing with standard tools from Apple, so we have to basically roll our own. I see this design following in the exact same footsteps.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I’m not sure I understand.</div></div></div></div></blockquote><div><br class=""></div><div>Every time you run “swift build” it’s going to trigger a build. This is should <i class="">never</i>&nbsp;be required to run tests. Even if you say, “we’ll only re-build on incremental builds”, you are assuming that you are building and running tests within the same environment and that the environment is a build-capable environment. This is not a valid assumption. This is what xcodebuild test does today, it tries to smartly only trigger builds when necessary, but since we build on one set of boxes and run tests on other machines, this simply doesn’t work.</div><div><br class=""></div><div>We have the opportunity to build a proper toolset that can be correctly used within many different workflows. However, I already see a lot of the coupling starting to happen today that has happened within xcodebuild already, and that really concerns me. Basically, it means that these tools aren’t going to be usable outside of the smaller-scale apps, and teams like mine are going to have to continue investing in more robust and flexible tools to enable our scenarios.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I think a lot of the design would be clarified by changing all of “by convention” items into realized default values in the Package.swift file. That would clearly demonstrate how the work and how we can change them.</div></div></div></blockquote><br class=""></div><div class="">Can you explain what you mean?</div></div></div></blockquote><br class=""></div><div>Show what the values for Package.swift are for this structure:</div><div><br class=""></div><div><div class=""><font face="Menlo" class="">Package</font></div><div class=""><font face="Menlo" class="">├── Sources</font></div><div class=""><font face="Menlo" class="">│ &nbsp; └── Foo</font></div><div class=""><font face="Menlo" class="">│ &nbsp; &nbsp; &nbsp; └──Foo.swift</font></div><div class=""><font face="Menlo" class="">└── Tests</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; └── Foo</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; └── Test.swift</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; └── Bar</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; └── Test.swift</font></div><div class=""><br class=""></div><div class="">Instead of it being “by convention”, show what actual layout of a Package.swift file looks like to achieve the same thing. We should be able to define a Package.swift file that does exactly the same thing.&nbsp;</div><div class=""><br class=""></div><div class="">-David</div></div><br class=""></body></html>