Skip to content

Parse specifer in swift-test #266

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
merged 1 commit into from
Apr 29, 2016
Merged

Conversation

aciidgh
Copy link
Contributor

@aciidgh aciidgh commented Apr 19, 2016

The specifier was not being parsed so is never passed to xctest.
swift test <test specifier>

@ddunbar
Copy link
Contributor

ddunbar commented Apr 19, 2016

Test case?

@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 19, 2016

This is in swift-test executable which is not testable right now I think

@ddunbar
Copy link
Contributor

ddunbar commented Apr 19, 2016

Why not? Seems like we should have at least one test that verifies its behavior in a functional style.

@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 19, 2016

something similar to XCTAssertBuilds ?

@kostiakoval
Copy link
Contributor

I don't think we want to actually invoke swift test. It would be better to invoke parse method and test the returned result.

@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 19, 2016

If I remember correctly importing an executable in test errors out with duplicate symbols for main

@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 20, 2016

I've updated the PR to include two functional tests for swift-test which executes swift-test executable on a fixture.
I also had to introduce flag -s for specifiers because wasn't able to get a flag with no flag from option parser, @mxcl suggest if there is a way to do that without adding this flag.

@@ -155,6 +155,44 @@ func executeSwiftBuild(_ chdir: String, configuration: Configuration = .Debug, p
}
}

func swiftTestPath() -> String {
#if os(OSX)
for bundle in NSBundle.allBundles() where bundle.bundlePath.hasSuffix(".xctest") {
Copy link
Contributor

@mxcl mxcl Apr 20, 2016

Choose a reason for hiding this comment

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

Every time you copy/pasta a kitten dies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

saved the kitten in 852af2e

@aciidgh aciidgh force-pushed the swift-test-fix branch 2 times, most recently from 852af2e to db95a20 Compare April 21, 2016 08:41
@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 21, 2016

rebased fixed conflicts

@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 24, 2016

Looks like CI is working again, @ddunbar @mxcl can you run it on this

@ddunbar
Copy link
Contributor

ddunbar commented Apr 24, 2016

@swift-ci please test

@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 24, 2016

This passes tests on my linux VM but Linux CI is failing with this error :

output: Compile Swift Module 'SwiftTestModule' (1 sources)
Compile Swift Module 'SwiftTestModuleTestSuite' (1 sources)
/tmp/ValidLayouts_SwiftTestModule.geloaT/SwiftTestModule/Tests/SwiftTestModule/SwiftTest.swift:2:8: error: no such module 'XCTest'
import XCTest
       ^
<unknown>:0: error: build had 1 command failures
swift-test: error: exit(1): /home/buildnode/jenkins/workspace/swift-package-manager-PR-Linux/buildbot_linux/swiftpm-linux-x86_64/debug/swift-build-tool -f /tmp/ValidLayouts_SwiftTestModule.geloaT/SwiftTestModule/.build/debug.yaml test

swift-test: /home/buildnode/jenkins/workspace/swift-package-manager-PR-Linux/buildbot_linux/swiftpm-linux-x86_64/debug/swift-test
/home/buildnode/jenkins/workspace/swift-package-manager-PR-Linux/swiftpm/Tests/Functional/SwiftTestTests.swift:18: error: SwiftTestTests.testSwiftTestTests : failed - `swift test []' failed:

exit(1): /home/buildnode/jenkins/workspace/swift-package-manager-PR-Linux/buildbot_linux/swiftpm-linux-x86_64/debug/swift-test --chdir /tmp/ValidLayouts_SwiftTestModule.geloaT/SwiftTestModule

Test Case 'SwiftTestTests.testSwiftTestTests' failed (0.708 seconds).

@mxcl @modocache any idea?

@briancroom
Copy link
Contributor

Here's what I think is going on.

When executing in the CI environment, no swift toolchain is present, so XCTest is only available in the build directory chosen by the Swift build-script-impl. SwiftPM's bootstrap script receives a parameter with the path to the XCTest build directory (https://github.com/apple/swift/blob/master/utils/build-script-impl#L1417), and passes that through when invoking SwiftPM (https://github.com/apple/swift-package-manager/blob/master/Utilities/bootstrap#L639). I guess a mechanism will need to be introduced here to provide the XCTest build path when running these tests as well.

@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 24, 2016

hmm if Utilities/bootstrap test also receives the same argument I can probably pass it further? maybe for now I can disable this test for linux.
@mxcl @ddunbar thoughts?

@kostiakoval
Copy link
Contributor

It's the same error I experience before when tried to invoke swift test .
#143

@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 24, 2016

thanks @kostiakoval for digging this out. Quoting Max's reply on that PR:

I've tried to make this work on Linux and my conclusion is we shouldn't bother with this test:

It is hard to make this work in the context of a full build of swift since the paths for XCTest and Foundation are not in the standard "toolchain" shape.
We are always testing swift-test because we use swift-test to test ourselves.
Instead we could add an integration test, but really we don't even need to because we test swift-test when we test ourselves.

So I'd like to close this, if there are no objections.

If this is still valid then can someone suggest another way to test this.

@kostiakoval
Copy link
Contributor

@aciidb0mb3r Could you income parse function and check returned mode? if the mode is correct than the option parser works correctly. I think it's enough to unit test this part and we don't need to invoke swift test

@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 24, 2016

Unit tests are not possible on executables right now due to duplicated main symbols

@ddunbar
Copy link
Contributor

ddunbar commented Apr 28, 2016

Sounds like we should remove the unit test from here, merge this and separately track finding a way to unit test this code? Any objections there?

@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 28, 2016

@ddunbar no objections, updated PR

@aciidgh
Copy link
Contributor Author

aciidgh commented Apr 29, 2016

@mxcl @ddunbar ci over here pls 🤖👋

@mxcl
Copy link
Contributor

mxcl commented Apr 29, 2016

@swift-ci Please test and merge

@swift-ci swift-ci merged commit 311ec17 into swiftlang:master Apr 29, 2016
@aciidgh aciidgh deleted the swift-test-fix branch May 10, 2016 06:07
aciidgh pushed a commit to aciidgh/swift-package-manager that referenced this pull request Jan 11, 2019
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.

6 participants