-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Generate boilerplate code for XCTest on linux using AST #164
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
Conversation
} | ||
|
||
try fputs("])\n\n", file) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline please :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I need to go over and refactor a bit. just wanted to make it work and get opinion before ending up wasting a lot of time heading in wrong direction 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Fair, I jumped right into the code, didn't read the description first 😇
Please don't use |
try write(" other-args: ", args + otherArgs) | ||
try write(" sources: ", module.sources.paths) | ||
try write(" sources: ", module.sources.paths + (testGenFile != nil ? ["\(testGenFile!).swift"] : [])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you assuming that tests will never be compiled in Release mode? Otherwise you'd need to add the new generated files down in the .Release branch as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was totally a work around just to see if it was working, as mentioned in description this file needs refactoring.... I don't even like what I did here 😆
Yeah, I understand. #156 (comment) I'll update the PR when the stable form for swiftpm comes out. If its going to be long then should probably close this PR for now, @mxcl suggestions? |
name: "swift-build", | ||
dependencies: ["Get", "Transmute", "Build", "Multitool"]), | ||
Target( | ||
name: "swift-test", | ||
dependencies: ["Multitool"]), | ||
dependencies: ["Multitool", "ASTParser"]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bunch of trailing line-space here.
at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, thanks
3126e4e
to
8d57935
Compare
I mentioned this before but I want to bring it up again for further discussion. I feel pretty strongly that doing the AST parsing and code generation here would couple I realize that there is a lot of state involved in this process and that extracting the codegen could get tricky, but I'm envisioning that there could be a tool (ideally provided by # Produce a Swift file with the test manifest for a module
xctest-gen module-manifest -module-name module1 -build-dir build/dir -o output/testmanifest1.swift input/testfile1.swift input/testfile2.swift
# Produce a Swift file with the test entrypoint
xctest-gen main -o output/testmain.swift output/testmanifest1.swift SwfitPM would thus be responsible for choosing output filenames so that it could include those new files in the Does this seem at all reasonable to you guys? Am I overestimating the value of splitting this out? |
@briancroom I like the idea of this being in XCTest rather than in Swiftpm. I think it would a good idea if this is moved there once the new ast mode comes out |
Totally agree with this being in XCTest. |
Does XCTest have a binary tool on Linux already? |
Someone has to write that code. To me it is a minor detail if this is in XCTest or here. Really introducing a new binary for XCTest seems wrong. Especially since once we have Reflection we won't need it. To me it seems like SwiftPM should do this. |
First of all, I'm really excited to see this test manifest tool come into existence, regardless of where it resides. Thanks for everyone's work on this! 💯 Here's my two cents:
On the other hand, in the short-term, I suppose it would be easier to implement test manifest generation if it were baked into SwiftPM--we wouldn't have to worry about how the new XCTest tool and SwiftPM interface with one another. So I guess I could understand if we chose to include this tool in SwiftPM, under the following assumptions:
And that's all I'll say on the matter! 😅 I'm sure whatever we decide will be great. |
As I think more on this, I think the interaction between SwiftPM (which knows how to find the test files) and this tool (which knows about how to parse those files) may actually be quite complex. I suppose we could define a custom Sorry if my comment above gave the impression that I was trivializing the problem! 🙇 |
…e-removal-description Add roots to verbose description of `StaleFileRemovalCommand`
About the implementation:
tests-ast
which will dump ast files of all the test modules in.build/debug/TestsAST
folder whenswift test
is runASTParser
, which is fed the directory containing ast dumps and it gives back an array ofTestModule
which is :generate()
method which is mostly @czechboy0's implementation#if
directive and outputs imbalanced tree so I made changes in couple of tests.Todo :
-disable-ast-gen
option in case this behaves badly for some users