Commit Graph

22 Commits

Author SHA1 Message Date
Daniel Rodríguez Troitiño
ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00
Rintaro Ishizaki
2f7aa428db [Macros] In-process plugin server
Separate swift-syntax libs for the compiler and for the library plugins.
Compiler communicates with library plugins using serialized messages
just like executable plugins.

* `lib/swift/host/compiler/lib_Compiler*.dylib`(`lib/CompilerSwiftSyntax`):
  swift-syntax libraries for compiler. Library evolution is disabled.
* Compiler (`ASTGen` and `swiftIDEUtilsBridging`) only depends on
  `lib/swift/host/compiler` libraries.
* `SwiftInProcPluginServer`: In-process plugin server shared library.
  This has one `swift_inproc_plugins_handle_message` entry point that
  receives a message and return the response.
* In the compiler
  * Add `-in-process-plugin-server-path` front-end option, which specifies
    the `SwiftInProcPluginServer` shared library path.
  * Remove `LoadedLibraryPlugin`, because all library plugins are managed
    by `SwiftInProcPluginServer`
  * Introduce abstract `CompilerPlugin` class that has 2 subclasses:
    * `LoadedExecutablePlugin` existing class that represents an
      executable plugin
    * `InProcessPlugins` wraps `dlopen`ed `SwiftInProcPluginServer`
  * Unified the code path in `TypeCheckMacros.cpp` and `ASTGen`, the
    difference between executable plugins and library plugins are now
    abstracted by `CompilerPlugin`
2024-06-17 11:36:52 -07:00
Doug Gregor
e7be8f32f1 Provide the lexical context to macro expansions 2024-02-02 16:03:29 -08:00
Steven Wu
407674ea52 [Test] Fix the wrong subsitution of swift-frontend-target in tests
There is no `%swift-frontend-target` subsitution in test, which is
actually `%target-swift-frontend`. The wrong spelling is actually
interpreted by lit as `%swift`-frontend-target, and surprising didn't
break any tests as the last argument from subsitution is
`-define-availability` so it just leads to an very akward availability
definition.
2023-12-18 16:07:48 -08:00
Rintaro Ishizaki
c587705924 Revert "XFAIL macro tests failing in ASAN bot"
This reverts commit 26122f6f80.
2023-12-04 13:38:54 -08:00
Becca Royal-Gordon
26122f6f80 XFAIL macro tests failing in ASAN bot 2023-12-04 11:08:27 -08:00
Daniel Rodríguez Troitiño
5d2e4a380c [test] Replace %swift-build-cxx-plugin with %swift-build-c-plugin (#70188)
As pointed out in https://github.com/apple/swift/pull/70136#discussion_r1411417454
the substitution name does not make sense because we are compiling
C code, not C++.

This should not introduce any behavioural changes.
2023-12-04 09:24:35 -08:00
Rintaro Ishizaki
efcebe3538 [Macros] Update a test case for ABI name changes
JSON decoder's error message include the ABI name specified by
'-module-abi-name'.
2023-10-16 14:36:31 -07:00
Saleem Abdulrasool
af79bc2d3f test: introduce a helper for building mock plugins
Introduce a helper for mock plugins as `-rpath` is not a portable
construct.  This allows running more of the macro tests on Windows.
2023-09-04 11:02:25 -07:00
Saleem Abdulrasool
466ef0c5a9 test: loosen expectations to support Windows
The paths are not handled uniformly which makes it difficult to match
the build directory pattern.  This is needed to handle the tests on
Windows.
2023-09-04 08:16:28 -07:00
Saleem Abdulrasool
bc9ee85aa4 Merge pull request #68308 from compnerd/tee
tests: remove gratuitous use of `tee`
2023-09-04 07:58:35 -07:00
Saleem Abdulrasool
046b3ffd27 tests: remove gratuitous use of tee
Replace the use of `tee` with proper redirection for the output.  This
reduces the dependency on Unix tools for portability.
2023-09-03 20:57:06 -07:00
Saleem Abdulrasool
2ed10a72b1 tests: add missing env
The `env` is required to set the environment variable as executing with
environment variables is a SysV Shell thing and is not generally
portable.  This is required to support Windows.
2023-09-03 20:55:19 -07:00
Rintaro Ishizaki
3e9c2536f6 [Macros] Unify PluginMessages.swift
Use PluginMessages.swift in swift-syntax consistently.
2023-06-29 13:04:10 -07:00
Rintaro Ishizaki
eefe9dc7ef [Macros] Attached macro expansions return single string
* Move collapse(expansions:for:attachedTo:) to SwiftSyntaxMacroExpansion
* SwiftSyntaxMacroExpansion.expandAttachedMacro() now perform collapsing
* SwiftSyntaxMacroExpansion.expandAttachedMacroWithoutCollapsing()
  to keep old behavior
* IPC request 'getCapability' now sends the host protocol version
* Unified IPC response 'macroExpansionResult' that returns single string
  for both 'expandFreestandingMacro' and 'expandAttachedMacro'
* Compiler accepts old 'expandFreestandingMacroResult' and
  'expandAttachedMacroResult' to keep compatibility
* Plugins check the compiler's protcol version to see if it suppports
  'macroExpansionResult', and fall back to old behavior if necessary
2023-06-26 11:04:59 -07:00
Doug Gregor
3c04cff8dd [Macros] Provide the freestanding macro role for expansion operations.
The compiler knows (from a macro declaration) what freestanding macro
role a macro implementation is expected to implement. Pass that through
to the macro expansion code itself, rather than guessing based on the
protocol conformances of the implementation type. We already use this
approach with attached macros, so this is more of the same.

Eliminates a crash and improves diagnostics when the freestanding macro
role and its implementation are out of sync, fixing rdar://110418969.
2023-06-09 12:59:56 -07:00
Rintaro Ishizaki
e181a4d39c [Macros] Improve error handling for plugin errors 2023-05-04 14:40:28 -07:00
Ben Barham
e5a28caa9a [Test] Fix swift_swift_parser feature and use in tests
The macro tests were all using "REQUIRES: OS=macosx" as a proxy for
"have the Swift Swift parser". There was an existing feature for this,
but it was just checking whether the path was passed through. Fix that
to use the same variable as in CMake.

Also remove all extraneous `-I` and `-L` to the host libs in the target
invocations.
2023-04-03 09:25:03 -07:00
Rintaro Ishizaki
1d2fd4223f [Test] Add %host_triple and %host_sdkroot substitutions
Macro tests need to build host libraries/tools. We can't use %target-*
substitutions for that.

rdar://107398734
2023-03-31 07:41:41 -07:00
Rintaro Ishizaki
d5b8c84d5b [Macros] Use SWIFT_DUMP_PLUGIN_MESSAGING to test exectuable plugins
And stop using '-dump-macro-expansions'
2023-03-24 16:39:30 -07:00
Rintaro Ishizaki
a49ab25ae8 [Macros] Recovery after executable plugin crash
When executable plugins crashed or somehow decided to exit, the compiler
should relaunch the plugin executable before sending another message.
2023-03-23 22:26:42 -07:00
Rintaro Ishizaki
a6e0191bc0 [Macros] Improve error handling for executable macro plugins
* Handle broken pipe
* Handle invalid response (malformed message, unexpected message kind)
2023-03-02 17:40:55 -08:00