Skip to content

Added -help option to sourcekitd-test #8746

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 24, 2017
Merged

Conversation

felix91gr
Copy link
Contributor

@felix91gr felix91gr commented Apr 13, 2017

What the PR includes

Addresses one of the current starter bugs, adding the feature mentioned in the title.

I've added a FIXME: in the printHelp function to suggest a possible expansion for its functionality (allowing to hide/include certain options from the Help Text). I don't think that's necessary for this command, but could be useful if we want it to have as many options as Driver.cpp has.

Where has this been tested

I've compiled this in Linux, using a slightly modified version of the default presets. I used #8485 and #8189, and added a cmake option to compile sourcekitd-test. It passed the buildbot_linux, smoketest tests on my pc 👍

Resolves SR-1421.

@felix91gr
Copy link
Contributor Author

@swift-ci please smoke test

@slavapestov
Copy link
Contributor

@swift-ci Please test

@nkcsgexi
Copy link
Contributor

Can we add a test to ensure this dump the -h option itself?

@felix91gr
Copy link
Contributor Author

🤔 sure... I can add that

@felix91gr
Copy link
Contributor Author

felix91gr commented Apr 18, 2017

Do we have a documentation on the testing tools? I'm talking about the kind of tests found in swift/test

EDIT

Found it! FileCheck and Testing Guide

@felix91gr
Copy link
Contributor Author

@nkcsgexi I made this test and it passed. Should I test something else as well?

// Basic check that usage works
//
// RUN: %sourcekitd-test -help | %FileCheck %s
//
// CHECK: USAGE: sourcekitd-test [options] <inputs>

@nkcsgexi
Copy link
Contributor

Thank you! @swift-ci please smoke test

@felix91gr
Copy link
Contributor Author

felix91gr commented Apr 18, 2017 via email

@nkcsgexi
Copy link
Contributor

@felix91gr could you push your test and ask swift CI to test it for you?

@felix91gr
Copy link
Contributor Author

felix91gr commented Apr 18, 2017 via email

@nkcsgexi
Copy link
Contributor

@swift-ci please smoke test

@felix91gr
Copy link
Contributor Author

please smoke test

Thanks! ^^

@nkcsgexi
Copy link
Contributor

@felix91gr whenever you need to trigger CI, just comment on the pull request to ask some one to trigger it for you. I'm sure many are glad to help 🙂

@felix91gr
Copy link
Contributor Author

It failed, this is the output:

Command Output (stderr):
--
error: unknown argument: -this_option_does_not_exist
Use -h or -help for assistance
FileCheck error: '-' is empty.
FileCheck command line:  /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/llvm-macosx-x86_64/./bin/FileCheck /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/swift/test/SourceKit/Misc/wrong_arguments.swift

--

From that, only the first two lines are the output of sourcekitd-test. That's the correct output (what we are testing, in fact). I have problems interpreting the FileCheck error though... what does...

FileCheck error: '-' is empty. mean?

This is the original test, btw:

// RUN: %sourcekitd-test -this_option_does_not_exist | %FileCheck %s
//
// CHECK: error: unknown argument:
// CHECK: Use -h or -help for assistance

Should I use the complete line? (like // CHECK: error: unknown argument: -this_option_does_not_exist)

I thought CHECK didn't enforce the line to be exactly equal... I wanted to give freedom to have any erroneous option in the test, just in case.

(Meta)

🤔 it failed only on OS X... Now that I look at it, the entire SourceKit test suite is disabled in Linux.

Ah, right. We haven't yet merged Norio Nomura's PR #8485. Well, I'll test it on my machine as well then (I'm using Linux) 👍

@felix91gr
Copy link
Contributor Author

Yup, the CHECK string must be matched exactly. That must've been the error.

@nkcsgexi I've submitted a correction. Can you call Swift-CI please? :)

@nkcsgexi
Copy link
Contributor

@swift-ci please smoke test

@felix91gr
Copy link
Contributor Author

🤔 both failed... that's weird.

Well, I'll restart my setup and keep at it.

@felix91gr
Copy link
Contributor Author

@benlangmuir or @nkcsgexi, I think I fixed the tests this time... sorry to bother you, could you run a smoke test please? :)

@nkcsgexi
Copy link
Contributor

@swift-ci please smoke test

@felix91gr
Copy link
Contributor Author

felix91gr commented Apr 20, 2017

@benlangmuir or @nkcsgexi... Sorry to bother you again. This time I've tested the changes using a local version of FileCheck. It should work. If it doesn't... 🤔 we'll see.

(please call CI ^^)

@nkcsgexi
Copy link
Contributor

@swift-ci please smoke test

@felix91gr
Copy link
Contributor Author

Wohoo! The wrong_arguments.swift test passed! I'm making it work :D

Next up, I'll fix whatever is wrong with the usage.swift test ✊

@felix91gr
Copy link
Contributor Author

I think I know what's the problem. I'll upload the change.

@felix91gr
Copy link
Contributor Author

The problem was that I thought the -help command returned 0, because it doesn't trigger an error. I was wrong.

In the design of sourcekitd-test, any option that makes the program not test a SourceKit request, returns 1. If the "happy path" would be to parse a request and perform a SourceKit test on it, then anything but the happy path returns 1. Therefore, both of my tests (wrong_arguments and usage should expect a 1 for result, and therefore should start with {// RUN: not sourcekitd-test ...}. Which now, they do :) (I tried it first with wrong_arguments, and it passes)

So, for (hopefully) last time... @nkcsgexi could you call CI? :)

@nkcsgexi
Copy link
Contributor

@swift-ci please smoke test

@felix91gr
Copy link
Contributor Author

Aw yeah! It passed! :D

@felix91gr
Copy link
Contributor Author

felix91gr commented Apr 21, 2017

It passed all the tests now!
Thanks for your patience, @nkcsgexi 😄

It was a dumb mistake, as it always is :D

@felix91gr
Copy link
Contributor Author

Should we merge this? Should I add something else? 🙂

@nkcsgexi
Copy link
Contributor

Could you squash all commits into one?

@felix91gr
Copy link
Contributor Author

felix91gr commented Apr 21, 2017 via email

@felix91gr
Copy link
Contributor Author

Done! :)

@nkcsgexi
Copy link
Contributor

👍 @swift-ci please smoke test and merge

@felix91gr
Copy link
Contributor Author

🤔 seems like nothing happened...

@nkcsgexi
Copy link
Contributor

Let's try again. @swift-ci please smoke test

@felix91gr
Copy link
Contributor Author

felix91gr commented Apr 21, 2017

Ahhh... you know, probably when asked for a test + merge process, it puts the task way back into the queue because the tasks before it where called using the previous state of the repo :D (w/o the merge)

If that's the case, then it should take a while sometimes, depending on how busy CI is 🤔

@@ -708,7 +708,7 @@ install-llbuild
install-swiftpm
install-xctest
install-prefix=/usr
swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license
swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license;sourcekit-inproc
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems irrelevant, is this change intentional ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh. I didn't notice. It's a leftover of one of my cherrypicks from Nomura's PR (#8485). Helped me test things in linux.
It can, and probably should, be removed... even though that PR has already been aprooved. You can do it if you want, or just wait for me (atm I'm not at the computer) :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the change when you can, and afterwards we can merge your improvements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oki doke 🙂👍🏻

@felix91gr felix91gr force-pushed the master branch 3 times, most recently from 3e301c2 to 51521ef Compare April 22, 2017 02:37
@felix91gr
Copy link
Contributor Author

@akyrtzi done 😉

Added "-help" option to Options.td
Added also:
* Added "OPT_HELP" case in the main TestOptions.cpp switch. It uses the llvm options help functionality to provide up-to-date help
* Additional "Use -help for assistance" at the end of the error message that appears when calling an unknown option
Added their following tests, respectively::
* usage.swift, and
* wrong_arguments.swift

Extra: FIXME: in TestOptions::printHelp, suggesting a possible expansion for the printHelp option (details in file)
@felix91gr
Copy link
Contributor Author

Updated

  • I deleted everything that was not needed:
    • A //WIP comment that I made in TestOptions.cpp, and
    • The ;sourcekit-inproc install option in the build presets that I used for testing.
  • I also added:
    • A brief documentation on the new tests, and
    • A newline that was missing at the end of TestOptions.cpp

I think we're ready for a test and merge. @nkcsgexi or @akyrtzi could you please call CI again? :)

@akyrtzi
Copy link
Contributor

akyrtzi commented Apr 24, 2017

@swift-ci smoke test and merge

@akyrtzi
Copy link
Contributor

akyrtzi commented Apr 24, 2017

@swift-ci smoke test

@felix91gr
Copy link
Contributor Author

What a weird thing... why did it fail the smoke test & merge, but passed the smoke test alone?

The only thing I can think of is that I haven't set gpg keys for my Github account. That could be it 🤔

@felix91gr
Copy link
Contributor Author

No, wait... it says "wrong SHA". 🤔
What made the SHA change?

@akyrtzi akyrtzi merged commit be12528 into swiftlang:master Apr 24, 2017
@felix91gr
Copy link
Contributor Author

😄

Thanks for the help and the patience, guys! @nkcsgexi and @akyrtzi specially :)

@nkcsgexi
Copy link
Contributor

@felix91gr congrats for your first Swift contribution! 👍

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.

4 participants