-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Macros] Add a library to make simple executable plugins for testing #63927
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
@swift-ci Please smoke test |
45cb439
to
548e896
Compare
@swift-ci Please smoke test |
@bnbarham wdyt? |
548e896
to
38cf3a4
Compare
@swift-ci Please smoke test |
Add `_swiftMockPlugin` library. Usage: #include "swift/swift-c/MockPlugin/MockPlugin.h" MOCK_PLUGIN([ {"expect": {...}, "response: {...}} ])
38cf3a4
to
761cbb0
Compare
@swift-ci Please smoke test |
@swift-ci Please smoke test Linux |
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.
I haven't fully reviewed the plugin itself, but yeah, this looks better to me. Thanks :).
Ideally we'd also have the current test plugin as a tool and then we could have a lit substitution for that as well.
// RUN: %clang \ | ||
// RUN: -isysroot %sdk \ | ||
// RUN: -I %swift_src_root/include \ | ||
// RUN: -L %swift-lib-dir -l_swiftMockPlugin \ | ||
// RUN: -Wl,-rpath,%swift-lib-dir \ | ||
// RUN: -o %t/mock-plugin \ | ||
// RUN: %t/plugin.c |
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.
You could add a lit.cfg substitution that handles the flags part of this
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.
Let's do it when we introduce second usage.
// RUN: %swift-target-frontend \ | ||
// RUN: -typecheck -verify \ | ||
// RUN: -swift-version 5 -enable-experimental-feature Macros \ | ||
// RUN: -load-plugin-executable %t/mock-plugin#TestPlugin \ |
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.
Could maybe also have a substitution for this one that could take an optional name... not sure how useful it would be though.
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.
the binary name (mock-plugin
) and the module name (TestPlugin
) are both test-file-specific.
I don't think we can reuse much.
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.
I'd be fine with them all being mock-plugin/TestPlugin :P. But you could give them as inputs 🤷
Add
_swiftMockPlugin
library.Usage:
Replaces
utils/mock_plugin.py