Skip to content

[1/2][build_script.py] Add "test" subcommand #57

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

Merged

Conversation

modocache
Copy link
Contributor

What's in this pull request?

This "FIXME" describes a problem with the swift-corelibs-xctest build script when invoked in the context of the greater Swift build script: https://github.com/apple/swift/blob/6ccf5da2dfc8a74c84b2fd99c32dcdf2255699d7/utils/build-script-impl#L2070-L2072

The problem is that there is currently no way to test an already built XCTest.so. Instead, the XCTest build script re-builds the entire project, then tests the newly build XCTest.so.

Add a "test" subcommand to build_script.py, which allows users to test an already built XCTest.so:

$ ./build_script.py test --swiftc `which swiftc` /path/to/build/dir

Users may still choose to build and test, by using the old build_script.py invocation:

$ ./build_script.py --swiftc `which swiftc` --test

Why merge this pull request?

The Swift build script is sort of disingenuous--maybe even dangerous--at the moment. When a user runs swift/utils/build-script --xctest --test, I think they'd expect that XCTest is built, then tested. In reality, it is built, then built again, then the second version is tested.

This gets even worse when we're talking about installing XCTest. In that case, it is:

  1. Built.
  2. Built again.
  3. The version that was just built is tested.
  4. It is built again.
  5. The final version to be built (which hasn't really been tested) is installed.

This pull request is a large change just to prevent step (2) above, but it puts in place the subcommand mechanism that we'll need to fix the install step (4).

What downsides are there to merging this pull request?

  1. It's a large change that touches most of the current build script.
  2. The subcommand parsing is admittedly wacky. I tried commenting why things were the way they were--for example, why we had to jump through hoops to get a "default subcommand".

Still, I think this is a significant improvement!

modocache added a commit to modocache/swift-corelibs-xctest that referenced this pull request Feb 28, 2016
This builds upon the subcommand system added in
swiftlang#57, to add
an install command.

As that pull request describes, because there is no way to test
or install XCTest without also building the project, the current
Swift build script ends up building XCTest three times. This adds
an "install" subcommand that allows an already built XCTest to be
installed.
@modocache modocache changed the title [build_script.py] Add "test" subcommand [1/2][build_script.py] Add "test" subcommand Feb 28, 2016
This "FIXME" describes a problem with the swift-corelibs-xctest build
script when invoked in the context of the greater Swift build script:
https://github.com/apple/swift/blob/6ccf5da2dfc8a74c84b2fd99c32dcdf2255699d7/utils/build-script-impl#L2070-L2072

The problem is that there is currently no way to test an *already
built* XCTest.so. Instead, the XCTest build script re-builds the entire
project, then tests the newly build XCTest.so.

Add a "test" subcommand to build_script.py, which allows users to test
an already built XCTest.so:

```
$ ./build_script.py test --swiftc `which swiftc` /path/to/build/dir
```

Users may still choose to build *and* test, by using the old
build_script.py invocation:

```
$ ./build_script.py --swiftc `which swiftc` --test
```
@modocache modocache force-pushed the build-script-subcommands-test branch from 1f719f3 to 2cbc592 Compare February 28, 2016 18:27
modocache added a commit to modocache/swift-corelibs-xctest that referenced this pull request Feb 28, 2016
This builds upon the subcommand system added in
swiftlang#57, to add
an install command.

As that pull request describes, because there is no way to test
or install XCTest without also building the project, the current
Swift build script ends up building XCTest three times. This adds
an "install" subcommand that allows an already built XCTest to be
installed.
@modocache
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@parkera
Copy link
Contributor

parkera commented Feb 29, 2016

@swift-ci please test

@mike-ferris
Copy link

This seems like a good thing to have.

mike-ferris pushed a commit that referenced this pull request Feb 29, 2016
[1/2][build_script.py] Add "test" subcommand
@mike-ferris mike-ferris merged commit e072d55 into swiftlang:master Feb 29, 2016
@modocache modocache deleted the build-script-subcommands-test branch February 29, 2016 23:59
modocache added a commit to modocache/swift-corelibs-xctest that referenced this pull request Mar 1, 2016
This builds upon the subcommand system added in
swiftlang#57, to add
an install command.

As that pull request describes, because there is no way to test
or install XCTest without also building the project, the current
Swift build script ends up building XCTest three times. This adds
an "install" subcommand that allows an already built XCTest to be
installed.
modocache added a commit to modocache/swift that referenced this pull request Mar 2, 2016
Prior to swiftlang/swift-corelibs-xctest#57 and
swiftlang/swift-corelibs-xctest#58, the
swift-corelibs-xctest build script did not provide a way an already
built XCTest.so to be tested or installed. As a result, the Swift
build script would build XCTest several times.

For example, the following invocation would build XCTest three separate
times:

```
$ utils/build-script --xctest --test -- --install-xctest
```

Modifications to the XCTest build script now allow a prebuilt XCTest to
be tested (via the `build_script.py test` subcommmand) and installed
(via the `build_script.py install` subcommand). Use these in the Swift
build script to build XCTest only once, then test and install the built
version.

Also, explicitly disable XCTest installation on OS X. XCTest's
`build_script.py` only supports non-Darwin platforms, so running
`utils/build-script --xctest -- --install-xctest` on OS X used to cause
the build script to fail because of how that script invokes `swiftc`.
It now fails with an explicit error indicating `--install-xctest` is
unsupported.
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.

3 participants