diff --git a/crates/wit-component/tests/interfaces/wasi-http.wat b/crates/wit-component/tests/interfaces/wasi-http.wat index e75781c785..b77097b8f1 100644 --- a/crates/wit-component/tests/interfaces/wasi-http.wat +++ b/crates/wit-component/tests/interfaces/wasi-http.wat @@ -874,7 +874,7 @@ ) ) (export (;7;) "proxy" (type 6)) - (@custom "package-docs" "\00{\22worlds\22:{\22proxy\22:{\22docs\22:\22The `wasi:http/proxy` world captures a widely-implementable intersection of\5cnhosts that includes HTTP forward and reverse proxies. Components targeting\5cnthis world may concurrently stream in and out any number of incoming and\5cnoutgoing HTTP requests.\22}},\22interfaces\22:{\22types\22:{\22docs\22:\22This interface defines all of the types and methods for implementing\5cnHTTP Requests and Responses, both incoming and outgoing, as well as\5cntheir headers, trailers, and bodies.\22,\22funcs\22:{\22http-error-code\22:\22Attempts to extract a http-related `error` from the wasi:io `error`\5cnprovided.\5cn\5cnStream operations which return\5cn`wasi:io/stream/stream-error::last-operation-failed` have a payload of\5cntype `wasi:io/error/error` with more information about the operation\5cnthat failed. This payload can be passed through to this function to see\5cnif there's http-related information about the error to return.\5cn\5cnNote that this function is fallible because not all io-errors are\5cnhttp-related errors.\22,\22[constructor]fields\22:\22Construct an empty HTTP Fields.\5cn\5cnThe resulting `fields` is mutable.\22,\22[static]fields.from-list\22:\22Construct an HTTP Fields.\5cn\5cnThe resulting `fields` is mutable.\5cn\5cnThe list represents each key-value pair in the Fields. Keys\5cnwhich have multiple values are represented by multiple entries in this\5cnlist with the same key.\5cn\5cnThe tuple is a pair of the field key, represented as a string, and\5cnValue, represented as a list of bytes. In a valid Fields, all keys\5cnand values are valid UTF-8 strings. However, values are not always\5cnwell-formed, so they are represented as a raw list of bytes.\5cn\5cnAn error result will be returned if any header or value was\5cnsyntactically invalid, or if a header was forbidden.\22,\22[method]fields.get\22:\22Get all of the values corresponding to a key. If the key is not present\5cnin this `fields`, an empty list is returned. However, if the key is\5cnpresent but empty, this is represented by a list with one or more\5cnempty field-values present.\22,\22[method]fields.has\22:\22Returns `true` when the key is present in this `fields`. If the key is\5cnsyntactically invalid, `false` is returned.\22,\22[method]fields.set\22:\22Set all of the values for a key. Clears any existing values for that\5cnkey, if they have been set.\5cn\5cnFails with `header-error.immutable` if the `fields` are immutable.\22,\22[method]fields.delete\22:\22Delete all values for a key. Does nothing if no values for the key\5cnexist.\5cn\5cnFails with `header-error.immutable` if the `fields` are immutable.\22,\22[method]fields.append\22:\22Append a value for a key. Does not change or delete any existing\5cnvalues for that key.\5cn\5cnFails with `header-error.immutable` if the `fields` are immutable.\22,\22[method]fields.entries\22:\22Retrieve the full set of keys and values in the Fields. Like the\5cnconstructor, the list represents each key-value pair.\5cn\5cnThe outer list represents each key-value pair in the Fields. Keys\5cnwhich have multiple values are represented by multiple entries in this\5cnlist with the same key.\22,\22[method]fields.clone\22:\22Make a deep copy of the Fields. Equivelant in behavior to calling the\5cn`fields` constructor on the return value of `entries`. The resulting\5cn`fields` is mutable.\22,\22[method]incoming-request.method\22:\22Returns the method of the incoming request.\22,\22[method]incoming-request.path-with-query\22:\22Returns the path with query parameters from the request, as a string.\22,\22[method]incoming-request.scheme\22:\22Returns the protocol scheme from the request.\22,\22[method]incoming-request.authority\22:\22Returns the authority from the request, if it was present.\22,\22[method]incoming-request.headers\22:\22Get the `headers` associated with the request.\5cn\5cnThe returned `headers` resource is immutable: `set`, `append`, and\5cn`delete` operations will fail with `header-error.immutable`.\5cn\5cnThe `headers` returned are a child resource: it must be dropped before\5cnthe parent `incoming-request` is dropped. Dropping this\5cn`incoming-request` before all children are dropped will trap.\22,\22[method]incoming-request.consume\22:\22Gives the `incoming-body` associated with this request. Will only\5cnreturn success at most once, and subsequent calls will return error.\22,\22[constructor]outgoing-request\22:\22Construct a new `outgoing-request` with a default `method` of `GET`, and\5cn`none` values for `path-with-query`, `scheme`, and `authority`.\5cn\5cn* `headers` is the HTTP Headers for the Request.\5cn\5cnIt is possible to construct, or manipulate with the accessor functions\5cnbelow, an `outgoing-request` with an invalid combination of `scheme`\5cnand `authority`, or `headers` which are not permitted to be sent.\5cnIt is the obligation of the `outgoing-handler.handle` implementation\5cnto reject invalid constructions of `outgoing-request`.\22,\22[method]outgoing-request.body\22:\22Returns the resource corresponding to the outgoing Body for this\5cnRequest.\5cn\5cnReturns success on the first call: the `outgoing-body` resource for\5cnthis `outgoing-request` can be retrieved at most once. Subsequent\5cncalls will return error.\22,\22[method]outgoing-request.method\22:\22Get the Method for the Request.\22,\22[method]outgoing-request.set-method\22:\22Set the Method for the Request. Fails if the string present in a\5cn`method.other` argument is not a syntactically valid method.\22,\22[method]outgoing-request.path-with-query\22:\22Get the combination of the HTTP Path and Query for the Request.\5cnWhen `none`, this represents an empty Path and empty Query.\22,\22[method]outgoing-request.set-path-with-query\22:\22Set the combination of the HTTP Path and Query for the Request.\5cnWhen `none`, this represents an empty Path and empty Query. Fails is the\5cnstring given is not a syntactically valid path and query uri component.\22,\22[method]outgoing-request.scheme\22:\22Get the HTTP Related Scheme for the Request. When `none`, the\5cnimplementation may choose an appropriate default scheme.\22,\22[method]outgoing-request.set-scheme\22:\22Set the HTTP Related Scheme for the Request. When `none`, the\5cnimplementation may choose an appropriate default scheme. Fails if the\5cnstring given is not a syntactically valid uri scheme.\22,\22[method]outgoing-request.authority\22:\22Get the HTTP Authority for the Request. A value of `none` may be used\5cnwith Related Schemes which do not require an Authority. The HTTP and\5cnHTTPS schemes always require an authority.\22,\22[method]outgoing-request.set-authority\22:\22Set the HTTP Authority for the Request. A value of `none` may be used\5cnwith Related Schemes which do not require an Authority. The HTTP and\5cnHTTPS schemes always require an authority. Fails if the string given is\5cnnot a syntactically valid uri authority.\22,\22[method]outgoing-request.headers\22:\22Get the headers associated with the Request.\5cn\5cnThe returned `headers` resource is immutable: `set`, `append`, and\5cn`delete` operations will fail with `header-error.immutable`.\5cn\5cnThis headers resource is a child: it must be dropped before the parent\5cn`outgoing-request` is dropped, or its ownership is transfered to\5cnanother component by e.g. `outgoing-handler.handle`.\22,\22[constructor]request-options\22:\22Construct a default `request-options` value.\22,\22[method]request-options.connect-timeout\22:\22The timeout for the initial connect to the HTTP Server.\22,\22[method]request-options.set-connect-timeout\22:\22Set the timeout for the initial connect to the HTTP Server. An error\5cnreturn value indicates that this timeout is not supported.\22,\22[method]request-options.first-byte-timeout\22:\22The timeout for receiving the first byte of the Response body.\22,\22[method]request-options.set-first-byte-timeout\22:\22Set the timeout for receiving the first byte of the Response body. An\5cnerror return value indicates that this timeout is not supported.\22,\22[method]request-options.between-bytes-timeout\22:\22The timeout for receiving subsequent chunks of bytes in the Response\5cnbody stream.\22,\22[method]request-options.set-between-bytes-timeout\22:\22Set the timeout for receiving subsequent chunks of bytes in the Response\5cnbody stream. An error return value indicates that this timeout is not\5cnsupported.\22,\22[static]response-outparam.set\22:\22Set the value of the `response-outparam` to either send a response,\5cnor indicate an error.\5cn\5cnThis method consumes the `response-outparam` to ensure that it is\5cncalled at most once. If it is never called, the implementation\5cnwill respond with an error.\5cn\5cnThe user may provide an `error` to `response` to allow the\5cnimplementation determine how to respond with an HTTP error response.\22,\22[method]incoming-response.status\22:\22Returns the status code from the incoming response.\22,\22[method]incoming-response.headers\22:\22Returns the headers from the incoming response.\5cn\5cnThe returned `headers` resource is immutable: `set`, `append`, and\5cn`delete` operations will fail with `header-error.immutable`.\5cn\5cnThis headers resource is a child: it must be dropped before the parent\5cn`incoming-response` is dropped.\22,\22[method]incoming-response.consume\22:\22Returns the incoming body. May be called at most once. Returns error\5cnif called additional times.\22,\22[method]incoming-body.stream\22:\22Returns the contents of the body, as a stream of bytes.\5cn\5cnReturns success on first call: the stream representing the contents\5cncan be retrieved at most once. Subsequent calls will return error.\5cn\5cnThe returned `input-stream` resource is a child: it must be dropped\5cnbefore the parent `incoming-body` is dropped, or consumed by\5cn`incoming-body.finish`.\5cn\5cnThis invariant ensures that the implementation can determine whether\5cnthe user is consuming the contents of the body, waiting on the\5cn`future-trailers` to be ready, or neither. This allows for network\5cnbackpressure is to be applied when the user is consuming the body,\5cnand for that backpressure to not inhibit delivery of the trailers if\5cnthe user does not read the entire body.\22,\22[static]incoming-body.finish\22:\22Takes ownership of `incoming-body`, and returns a `future-trailers`.\5cnThis function will trap if the `input-stream` child is still alive.\22,\22[method]future-trailers.subscribe\22:\22Returns a pollable which becomes ready when either the trailers have\5cnbeen received, or an error has occured. When this pollable is ready,\5cnthe `get` method will return `some`.\22,\22[method]future-trailers.get\22:\22Returns the contents of the trailers, or an error which occured,\5cnonce the future is ready.\5cn\5cnThe outer `option` represents future readiness. Users can wait on this\5cn`option` to become `some` using the `subscribe` method.\5cn\5cnThe outer `result` is used to retrieve the trailers or error at most\5cnonce. It will be success on the first call in which the outer option\5cnis `some`, and error on subsequent calls.\5cn\5cnThe inner `result` represents that either the HTTP Request or Response\5cnbody, as well as any trailers, were received successfully, or that an\5cnerror occured receiving them. The optional `trailers` indicates whether\5cnor not trailers were present in the body.\5cn\5cnWhen some `trailers` are returned by this method, the `trailers`\5cnresource is immutable, and a child. Use of the `set`, `append`, or\5cn`delete` methods will return an error, and the resource must be\5cndropped before the parent `future-trailers` is dropped.\22,\22[constructor]outgoing-response\22:\22Construct an `outgoing-response`, with a default `status-code` of `200`.\5cnIf a different `status-code` is needed, it must be set via the\5cn`set-status-code` method.\5cn\5cn* `headers` is the HTTP Headers for the Response.\22,\22[method]outgoing-response.status-code\22:\22Get the HTTP Status Code for the Response.\22,\22[method]outgoing-response.set-status-code\22:\22Set the HTTP Status Code for the Response. Fails if the status-code\5cngiven is not a valid http status code.\22,\22[method]outgoing-response.headers\22:\22Get the headers associated with the Request.\5cn\5cnThe returned `headers` resource is immutable: `set`, `append`, and\5cn`delete` operations will fail with `header-error.immutable`.\5cn\5cnThis headers resource is a child: it must be dropped before the parent\5cn`outgoing-request` is dropped, or its ownership is transfered to\5cnanother component by e.g. `outgoing-handler.handle`.\22,\22[method]outgoing-response.body\22:\22Returns the resource corresponding to the outgoing Body for this Response.\5cn\5cnReturns success on the first call: the `outgoing-body` resource for\5cnthis `outgoing-response` can be retrieved at most once. Subsequent\5cncalls will return error.\22,\22[method]outgoing-body.write\22:\22Returns a stream for writing the body contents.\5cn\5cnThe returned `output-stream` is a child resource: it must be dropped\5cnbefore the parent `outgoing-body` resource is dropped (or finished),\5cnotherwise the `outgoing-body` drop or `finish` will trap.\5cn\5cnReturns success on the first call: the `output-stream` resource for\5cnthis `outgoing-body` may be retrieved at most once. Subsequent calls\5cnwill return error.\22,\22[static]outgoing-body.finish\22:\22Finalize an outgoing body, optionally providing trailers. This must be\5cncalled to signal that the response is complete. If the `outgoing-body`\5cnis dropped without calling `outgoing-body.finalize`, the implementation\5cnshould treat the body as corrupted.\5cn\5cnFails if the body's `outgoing-request` or `outgoing-response` was\5cnconstructed with a Content-Length header, and the contents written\5cnto the body (via `write`) does not match the value given in the\5cnContent-Length.\22,\22[method]future-incoming-response.subscribe\22:\22Returns a pollable which becomes ready when either the Response has\5cnbeen received, or an error has occured. When this pollable is ready,\5cnthe `get` method will return `some`.\22,\22[method]future-incoming-response.get\22:\22Returns the incoming HTTP Response, or an error, once one is ready.\5cn\5cnThe outer `option` represents future readiness. Users can wait on this\5cn`option` to become `some` using the `subscribe` method.\5cn\5cnThe outer `result` is used to retrieve the response or error at most\5cnonce. It will be success on the first call in which the outer option\5cnis `some`, and error on subsequent calls.\5cn\5cnThe inner `result` represents that either the incoming HTTP Response\5cnstatus and headers have recieved successfully, or that an error\5cnoccured. Errors may also occur while consuming the response body,\5cnbut those will be reported by the `incoming-body` and its\5cn`output-stream` child.\22},\22types\22:{\22method\22:{\22docs\22:\22This type corresponds to HTTP standard Methods.\22},\22scheme\22:{\22docs\22:\22This type corresponds to HTTP standard Related Schemes.\22},\22DNS-error-payload\22:{\22docs\22:\22Defines the case payload type for `DNS-error` above:\22},\22TLS-alert-received-payload\22:{\22docs\22:\22Defines the case payload type for `TLS-alert-received` above:\22},\22field-size-payload\22:{\22docs\22:\22Defines the case payload type for `HTTP-response-{header,trailer}-size` above:\22},\22error-code\22:{\22docs\22:\22These cases are inspired by the IANA HTTP Proxy Error Types:\5cnhttps://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types\22,\22items\22:{\22internal-error\22:\22This is a catch-all error for anything that doesn't fit cleanly into a\5cnmore specific case. It also includes an optional string for an\5cnunstructured description of the error. Users should not depend on the\5cnstring for diagnosing errors, as it's not required to be consistent\5cnbetween implementations.\22}},\22header-error\22:{\22docs\22:\22This type enumerates the different kinds of errors that may occur when\5cnsetting or appending to a `fields` resource.\22,\22items\22:{\22invalid-syntax\22:\22This error indicates that a `field-key` or `field-value` was\5cnsyntactically invalid when used with an operation that sets headers in a\5cn`fields`.\22,\22forbidden\22:\22This error indicates that a forbidden `field-key` was used when trying\5cnto set a header in a `fields`.\22,\22immutable\22:\22This error indicates that the operation on the `fields` was not\5cnpermitted because the fields are immutable.\22}},\22field-key\22:{\22docs\22:\22Field keys are always strings.\22},\22field-value\22:{\22docs\22:\22Field values should always be ASCII strings. However, in\5cnreality, HTTP implementations often have to interpret malformed values,\5cnso they are provided as a list of bytes.\22},\22fields\22:{\22docs\22:\22This following block defines the `fields` resource which corresponds to\5cnHTTP standard Fields. Fields are a common representation used for both\5cnHeaders and Trailers.\5cn\5cnA `fields` may be mutable or immutable. A `fields` created using the\5cnconstructor, `from-list`, or `clone` will be mutable, but a `fields`\5cnresource given by other means (including, but not limited to,\5cn`incoming-request.headers`, `outgoing-request.headers`) might be be\5cnimmutable. In an immutable fields, the `set`, `append`, and `delete`\5cnoperations will fail with `header-error.immutable`.\22},\22headers\22:{\22docs\22:\22Headers is an alias for Fields.\22},\22trailers\22:{\22docs\22:\22Trailers is an alias for Fields.\22},\22incoming-request\22:{\22docs\22:\22Represents an incoming HTTP Request.\22},\22outgoing-request\22:{\22docs\22:\22Represents an outgoing HTTP Request.\22},\22request-options\22:{\22docs\22:\22Parameters for making an HTTP Request. Each of these parameters is\5cncurrently an optional timeout applicable to the transport layer of the\5cnHTTP protocol.\5cn\5cnThese timeouts are separate from any the user may use to bound a\5cnblocking call to `wasi:io/poll.poll`.\22},\22response-outparam\22:{\22docs\22:\22Represents the ability to send an HTTP Response.\5cn\5cnThis resource is used by the `wasi:http/incoming-handler` interface to\5cnallow a Response to be sent corresponding to the Request provided as the\5cnother argument to `incoming-handler.handle`.\22},\22status-code\22:{\22docs\22:\22This type corresponds to the HTTP standard Status Code.\22},\22incoming-response\22:{\22docs\22:\22Represents an incoming HTTP Response.\22},\22incoming-body\22:{\22docs\22:\22Represents an incoming HTTP Request or Response's Body.\5cn\5cnA body has both its contents - a stream of bytes - and a (possibly\5cnempty) set of trailers, indicating that the full contents of the\5cnbody have been received. This resource represents the contents as\5cnan `input-stream` and the delivery of trailers as a `future-trailers`,\5cnand ensures that the user of this interface may only be consuming either\5cnthe body contents or waiting on trailers at any given time.\22},\22future-trailers\22:{\22docs\22:\22Represents a future which may eventaully return trailers, or an error.\5cn\5cnIn the case that the incoming HTTP Request or Response did not have any\5cntrailers, this future will resolve to the empty set of trailers once the\5cncomplete Request or Response body has been received.\22},\22outgoing-response\22:{\22docs\22:\22Represents an outgoing HTTP Response.\22},\22outgoing-body\22:{\22docs\22:\22Represents an outgoing HTTP Request or Response's Body.\5cn\5cnA body has both its contents - a stream of bytes - and a (possibly\5cnempty) set of trailers, inducating the full contents of the body\5cnhave been sent. This resource represents the contents as an\5cn`output-stream` child resource, and the completion of the body (with\5cnoptional trailers) with a static function that consumes the\5cn`outgoing-body` resource, and ensures that the user of this interface\5cnmay not write to the body contents after the body has been finished.\5cn\5cnIf the user code drops this resource, as opposed to calling the static\5cnmethod `finish`, the implementation should treat the body as incomplete,\5cnand that an error has occured. The implementation should propogate this\5cnerror to the HTTP protocol by whatever means it has available,\5cnincluding: corrupting the body on the wire, aborting the associated\5cnRequest, or sending a late status code for the Response.\22},\22future-incoming-response\22:{\22docs\22:\22Represents a future which may eventaully return an incoming HTTP\5cnResponse, or an error.\5cn\5cnThis resource is returned by the `wasi:http/outgoing-handler` interface to\5cnprovide the HTTP Response corresponding to the sent Request.\22}}},\22incoming-handler\22:{\22docs\22:\22This interface defines a handler of incoming HTTP Requests. It should\5cnbe exported by components which can respond to HTTP Requests.\22,\22funcs\22:{\22handle\22:\22This function is invoked with an incoming HTTP Request, and a resource\5cn`response-outparam` which provides the capability to reply with an HTTP\5cnResponse. The response is sent by calling the `response-outparam.set`\5cnmethod, which allows execution to continue after the response has been\5cnsent. This enables both streaming to the response body, and performing other\5cnwork.\5cn\5cnThe implementor of this function must write a response to the\5cn`response-outparam` before returning, or else the caller will respond\5cnwith an error on its behalf.\22}},\22outgoing-handler\22:{\22docs\22:\22This interface defines a handler of outgoing HTTP Requests. It should be\5cnimported by components which wish to make HTTP Requests.\22,\22funcs\22:{\22handle\22:\22This function is invoked with an outgoing HTTP Request, and it returns\5cna resource `future-incoming-response` which represents an HTTP Response\5cnwhich may arrive in the future.\5cn\5cnThe `options` argument accepts optional parameters for the HTTP\5cnprotocol's transport layer.\5cn\5cnThis function may return an error if the `outgoing-request` is invalid\5cnor not allowed to be made. Otherwise, protocol errors are reported\5cnthrough the `future-incoming-response`.\22}}}}") + (@custom "package-docs" "\00{\22worlds\22:{\22proxy\22:{\22docs\22:\22The `wasi:http/proxy` world captures a widely-implementable intersection of\5cnhosts that includes HTTP forward and reverse proxies. Components targeting\5cnthis world may concurrently stream in and out any number of incoming and\5cnoutgoing HTTP requests.\22}},\22interfaces\22:{\22types\22:{\22docs\22:\22This interface defines all of the types and methods for implementing\5cnHTTP Requests and Responses, both incoming and outgoing, as well as\5cntheir headers, trailers, and bodies.\22,\22funcs\22:{\22http-error-code\22:\22Attempts to extract a http-related `error` from the wasi:io `error`\5cnprovided.\5cn\5cnStream operations which return\5cn`wasi:io/stream/stream-error::last-operation-failed` have a payload of\5cntype `wasi:io/error/error` with more information about the operation\5cnthat failed. This payload can be passed through to this function to see\5cnif there's http-related information about the error to return.\5cn\5cnNote that this function is fallible because not all io-errors are\5cnhttp-related errors.\22,\22[constructor]fields\22:\22Construct an empty HTTP Fields.\5cn\5cnThe resulting `fields` is mutable.\22,\22[static]fields.from-list\22:\22Construct an HTTP Fields.\5cn\5cnThe resulting `fields` is mutable.\5cn\5cnThe list represents each key-value pair in the Fields. Keys\5cnwhich have multiple values are represented by multiple entries in this\5cnlist with the same key.\5cn\5cnThe tuple is a pair of the field key, represented as a string, and\5cnValue, represented as a list of bytes. In a valid Fields, all keys\5cnand values are valid UTF-8 strings. However, values are not always\5cnwell-formed, so they are represented as a raw list of bytes.\5cn\5cnAn error result will be returned if any header or value was\5cnsyntactically invalid, or if a header was forbidden.\22,\22[method]fields.get\22:\22Get all of the values corresponding to a key. If the key is not present\5cnin this `fields`, an empty list is returned. However, if the key is\5cnpresent but empty, this is represented by a list with one or more\5cnempty field-values present.\22,\22[method]fields.has\22:\22Returns `true` when the key is present in this `fields`. If the key is\5cnsyntactically invalid, `false` is returned.\22,\22[method]fields.set\22:\22Set all of the values for a key. Clears any existing values for that\5cnkey, if they have been set.\5cn\5cnFails with `header-error.immutable` if the `fields` are immutable.\22,\22[method]fields.delete\22:\22Delete all values for a key. Does nothing if no values for the key\5cnexist.\5cn\5cnFails with `header-error.immutable` if the `fields` are immutable.\22,\22[method]fields.append\22:\22Append a value for a key. Does not change or delete any existing\5cnvalues for that key.\5cn\5cnFails with `header-error.immutable` if the `fields` are immutable.\22,\22[method]fields.entries\22:\22Retrieve the full set of keys and values in the Fields. Like the\5cnconstructor, the list represents each key-value pair.\5cn\5cnThe outer list represents each key-value pair in the Fields. Keys\5cnwhich have multiple values are represented by multiple entries in this\5cnlist with the same key.\22,\22[method]fields.clone\22:\22Make a deep copy of the Fields. Equivelant in behavior to calling the\5cn`fields` constructor on the return value of `entries`. The resulting\5cn`fields` is mutable.\22,\22[method]incoming-request.method\22:\22Returns the method of the incoming request.\22,\22[method]incoming-request.path-with-query\22:\22Returns the path with query parameters from the request, as a string.\22,\22[method]incoming-request.scheme\22:\22Returns the protocol scheme from the request.\22,\22[method]incoming-request.authority\22:\22Returns the authority from the request, if it was present.\22,\22[method]incoming-request.headers\22:\22Get the `headers` associated with the request.\5cn\5cnThe returned `headers` resource is immutable: `set`, `append`, and\5cn`delete` operations will fail with `header-error.immutable`.\5cn\5cnThe `headers` returned are a child resource: it must be dropped before\5cnthe parent `incoming-request` is dropped. Dropping this\5cn`incoming-request` before all children are dropped will trap.\22,\22[method]incoming-request.consume\22:\22Gives the `incoming-body` associated with this request. Will only\5cnreturn success at most once, and subsequent calls will return error.\22,\22[constructor]outgoing-request\22:\22Construct a new `outgoing-request` with a default `method` of `GET`, and\5cn`none` values for `path-with-query`, `scheme`, and `authority`.\5cn\5cn* `headers` is the HTTP Headers for the Request.\5cn\5cnIt is possible to construct, or manipulate with the accessor functions\5cnbelow, an `outgoing-request` with an invalid combination of `scheme`\5cnand `authority`, or `headers` which are not permitted to be sent.\5cnIt is the obligation of the `outgoing-handler.handle` implementation\5cnto reject invalid constructions of `outgoing-request`.\22,\22[method]outgoing-request.body\22:\22Returns the resource corresponding to the outgoing Body for this\5cnRequest.\5cn\5cnReturns success on the first call: the `outgoing-body` resource for\5cnthis `outgoing-request` can be retrieved at most once. Subsequent\5cncalls will return error.\22,\22[method]outgoing-request.method\22:\22Get the Method for the Request.\22,\22[method]outgoing-request.set-method\22:\22Set the Method for the Request. Fails if the string present in a\5cn`method.other` argument is not a syntactically valid method.\22,\22[method]outgoing-request.path-with-query\22:\22Get the combination of the HTTP Path and Query for the Request.\5cnWhen `none`, this represents an empty Path and empty Query.\22,\22[method]outgoing-request.set-path-with-query\22:\22Set the combination of the HTTP Path and Query for the Request.\5cnWhen `none`, this represents an empty Path and empty Query. Fails is the\5cnstring given is not a syntactically valid path and query uri component.\22,\22[method]outgoing-request.scheme\22:\22Get the HTTP Related Scheme for the Request. When `none`, the\5cnimplementation may choose an appropriate default scheme.\22,\22[method]outgoing-request.set-scheme\22:\22Set the HTTP Related Scheme for the Request. When `none`, the\5cnimplementation may choose an appropriate default scheme. Fails if the\5cnstring given is not a syntactically valid uri scheme.\22,\22[method]outgoing-request.authority\22:\22Get the HTTP Authority for the Request. A value of `none` may be used\5cnwith Related Schemes which do not require an Authority. The HTTP and\5cnHTTPS schemes always require an authority.\22,\22[method]outgoing-request.set-authority\22:\22Set the HTTP Authority for the Request. A value of `none` may be used\5cnwith Related Schemes which do not require an Authority. The HTTP and\5cnHTTPS schemes always require an authority. Fails if the string given is\5cnnot a syntactically valid uri authority.\22,\22[method]outgoing-request.headers\22:\22Get the headers associated with the Request.\5cn\5cnThe returned `headers` resource is immutable: `set`, `append`, and\5cn`delete` operations will fail with `header-error.immutable`.\5cn\5cnThis headers resource is a child: it must be dropped before the parent\5cn`outgoing-request` is dropped, or its ownership is transfered to\5cnanother component by e.g. `outgoing-handler.handle`.\22,\22[constructor]request-options\22:\22Construct a default `request-options` value.\22,\22[method]request-options.connect-timeout\22:\22The timeout for the initial connect to the HTTP Server.\22,\22[method]request-options.set-connect-timeout\22:\22Set the timeout for the initial connect to the HTTP Server. An error\5cnreturn value indicates that this timeout is not supported.\22,\22[method]request-options.first-byte-timeout\22:\22The timeout for receiving the first byte of the Response body.\22,\22[method]request-options.set-first-byte-timeout\22:\22Set the timeout for receiving the first byte of the Response body. An\5cnerror return value indicates that this timeout is not supported.\22,\22[method]request-options.between-bytes-timeout\22:\22The timeout for receiving subsequent chunks of bytes in the Response\5cnbody stream.\22,\22[method]request-options.set-between-bytes-timeout\22:\22Set the timeout for receiving subsequent chunks of bytes in the Response\5cnbody stream. An error return value indicates that this timeout is not\5cnsupported.\22,\22[static]response-outparam.set\22:\22Set the value of the `response-outparam` to either send a response,\5cnor indicate an error.\5cn\5cnThis method consumes the `response-outparam` to ensure that it is\5cncalled at most once. If it is never called, the implementation\5cnwill respond with an error.\5cn\5cnThe user may provide an `error` to `response` to allow the\5cnimplementation determine how to respond with an HTTP error response.\22,\22[method]incoming-response.status\22:\22Returns the status code from the incoming response.\22,\22[method]incoming-response.headers\22:\22Returns the headers from the incoming response.\5cn\5cnThe returned `headers` resource is immutable: `set`, `append`, and\5cn`delete` operations will fail with `header-error.immutable`.\5cn\5cnThis headers resource is a child: it must be dropped before the parent\5cn`incoming-response` is dropped.\22,\22[method]incoming-response.consume\22:\22Returns the incoming body. May be called at most once. Returns error\5cnif called additional times.\22,\22[method]incoming-body.stream\22:\22Returns the contents of the body, as a stream of bytes.\5cn\5cnReturns success on first call: the stream representing the contents\5cncan be retrieved at most once. Subsequent calls will return error.\5cn\5cnThe returned `input-stream` resource is a child: it must be dropped\5cnbefore the parent `incoming-body` is dropped, or consumed by\5cn`incoming-body.finish`.\5cn\5cnThis invariant ensures that the implementation can determine whether\5cnthe user is consuming the contents of the body, waiting on the\5cn`future-trailers` to be ready, or neither. This allows for network\5cnbackpressure is to be applied when the user is consuming the body,\5cnand for that backpressure to not inhibit delivery of the trailers if\5cnthe user does not read the entire body.\22,\22[static]incoming-body.finish\22:\22Takes ownership of `incoming-body`, and returns a `future-trailers`.\5cnThis function will trap if the `input-stream` child is still alive.\22,\22[method]future-trailers.subscribe\22:\22Returns a pollable which becomes ready when either the trailers have\5cnbeen received, or an error has occured. When this pollable is ready,\5cnthe `get` method will return `some`.\22,\22[method]future-trailers.get\22:\22Returns the contents of the trailers, or an error which occured,\5cnonce the future is ready.\5cn\5cnThe outer `option` represents future readiness. Users can wait on this\5cn`option` to become `some` using the `subscribe` method.\5cn\5cnThe outer `result` is used to retrieve the trailers or error at most\5cnonce. It will be success on the first call in which the outer option\5cnis `some`, and error on subsequent calls.\5cn\5cnThe inner `result` represents that either the HTTP Request or Response\5cnbody, as well as any trailers, were received successfully, or that an\5cnerror occured receiving them. The optional `trailers` indicates whether\5cnor not trailers were present in the body.\5cn\5cnWhen some `trailers` are returned by this method, the `trailers`\5cnresource is immutable, and a child. Use of the `set`, `append`, or\5cn`delete` methods will return an error, and the resource must be\5cndropped before the parent `future-trailers` is dropped.\22,\22[constructor]outgoing-response\22:\22Construct an `outgoing-response`, with a default `status-code` of `200`.\5cnIf a different `status-code` is needed, it must be set via the\5cn`set-status-code` method.\5cn\5cn* `headers` is the HTTP Headers for the Response.\22,\22[method]outgoing-response.status-code\22:\22Get the HTTP Status Code for the Response.\22,\22[method]outgoing-response.set-status-code\22:\22Set the HTTP Status Code for the Response. Fails if the status-code\5cngiven is not a valid http status code.\22,\22[method]outgoing-response.headers\22:\22Get the headers associated with the Request.\5cn\5cnThe returned `headers` resource is immutable: `set`, `append`, and\5cn`delete` operations will fail with `header-error.immutable`.\5cn\5cnThis headers resource is a child: it must be dropped before the parent\5cn`outgoing-request` is dropped, or its ownership is transfered to\5cnanother component by e.g. `outgoing-handler.handle`.\22,\22[method]outgoing-response.body\22:\22Returns the resource corresponding to the outgoing Body for this Response.\5cn\5cnReturns success on the first call: the `outgoing-body` resource for\5cnthis `outgoing-response` can be retrieved at most once. Subsequent\5cncalls will return error.\22,\22[method]outgoing-body.write\22:\22Returns a stream for writing the body contents.\5cn\5cnThe returned `output-stream` is a child resource: it must be dropped\5cnbefore the parent `outgoing-body` resource is dropped (or finished),\5cnotherwise the `outgoing-body` drop or `finish` will trap.\5cn\5cnReturns success on the first call: the `output-stream` resource for\5cnthis `outgoing-body` may be retrieved at most once. Subsequent calls\5cnwill return error.\22,\22[static]outgoing-body.finish\22:\22Finalize an outgoing body, optionally providing trailers. This must be\5cncalled to signal that the response is complete. If the `outgoing-body`\5cnis dropped without calling `outgoing-body.finalize`, the implementation\5cnshould treat the body as corrupted.\5cn\5cnFails if the body's `outgoing-request` or `outgoing-response` was\5cnconstructed with a Content-Length header, and the contents written\5cnto the body (via `write`) does not match the value given in the\5cnContent-Length.\22,\22[method]future-incoming-response.subscribe\22:\22Returns a pollable which becomes ready when either the Response has\5cnbeen received, or an error has occured. When this pollable is ready,\5cnthe `get` method will return `some`.\22,\22[method]future-incoming-response.get\22:\22Returns the incoming HTTP Response, or an error, once one is ready.\5cn\5cnThe outer `option` represents future readiness. Users can wait on this\5cn`option` to become `some` using the `subscribe` method.\5cn\5cnThe outer `result` is used to retrieve the response or error at most\5cnonce. It will be success on the first call in which the outer option\5cnis `some`, and error on subsequent calls.\5cn\5cnThe inner `result` represents that either the incoming HTTP Response\5cnstatus and headers have recieved successfully, or that an error\5cnoccured. Errors may also occur while consuming the response body,\5cnbut those will be reported by the `incoming-body` and its\5cn`output-stream` child.\22},\22types\22:{\22method\22:{\22docs\22:\22This type corresponds to HTTP standard Methods.\22},\22scheme\22:{\22docs\22:\22This type corresponds to HTTP standard Related Schemes.\22},\22DNS-error-payload\22:{\22docs\22:\22Defines the case payload type for `DNS-error` above:\22},\22TLS-alert-received-payload\22:{\22docs\22:\22Defines the case payload type for `TLS-alert-received` above:\22},\22field-size-payload\22:{\22docs\22:\22Defines the case payload type for `HTTP-response-{header,trailer}-size` above:\22},\22error-code\22:{\22docs\22:\22These cases are inspired by the IANA HTTP Proxy Error Types:\5cn https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types\22,\22items\22:{\22internal-error\22:\22This is a catch-all error for anything that doesn't fit cleanly into a\5cnmore specific case. It also includes an optional string for an\5cnunstructured description of the error. Users should not depend on the\5cnstring for diagnosing errors, as it's not required to be consistent\5cnbetween implementations.\22}},\22header-error\22:{\22docs\22:\22This type enumerates the different kinds of errors that may occur when\5cnsetting or appending to a `fields` resource.\22,\22items\22:{\22invalid-syntax\22:\22This error indicates that a `field-key` or `field-value` was\5cnsyntactically invalid when used with an operation that sets headers in a\5cn`fields`.\22,\22forbidden\22:\22This error indicates that a forbidden `field-key` was used when trying\5cnto set a header in a `fields`.\22,\22immutable\22:\22This error indicates that the operation on the `fields` was not\5cnpermitted because the fields are immutable.\22}},\22field-key\22:{\22docs\22:\22Field keys are always strings.\22},\22field-value\22:{\22docs\22:\22Field values should always be ASCII strings. However, in\5cnreality, HTTP implementations often have to interpret malformed values,\5cnso they are provided as a list of bytes.\22},\22fields\22:{\22docs\22:\22This following block defines the `fields` resource which corresponds to\5cnHTTP standard Fields. Fields are a common representation used for both\5cnHeaders and Trailers.\5cn\5cnA `fields` may be mutable or immutable. A `fields` created using the\5cnconstructor, `from-list`, or `clone` will be mutable, but a `fields`\5cnresource given by other means (including, but not limited to,\5cn`incoming-request.headers`, `outgoing-request.headers`) might be be\5cnimmutable. In an immutable fields, the `set`, `append`, and `delete`\5cnoperations will fail with `header-error.immutable`.\22},\22headers\22:{\22docs\22:\22Headers is an alias for Fields.\22},\22trailers\22:{\22docs\22:\22Trailers is an alias for Fields.\22},\22incoming-request\22:{\22docs\22:\22Represents an incoming HTTP Request.\22},\22outgoing-request\22:{\22docs\22:\22Represents an outgoing HTTP Request.\22},\22request-options\22:{\22docs\22:\22Parameters for making an HTTP Request. Each of these parameters is\5cncurrently an optional timeout applicable to the transport layer of the\5cnHTTP protocol.\5cn\5cnThese timeouts are separate from any the user may use to bound a\5cnblocking call to `wasi:io/poll.poll`.\22},\22response-outparam\22:{\22docs\22:\22Represents the ability to send an HTTP Response.\5cn\5cnThis resource is used by the `wasi:http/incoming-handler` interface to\5cnallow a Response to be sent corresponding to the Request provided as the\5cnother argument to `incoming-handler.handle`.\22},\22status-code\22:{\22docs\22:\22This type corresponds to the HTTP standard Status Code.\22},\22incoming-response\22:{\22docs\22:\22Represents an incoming HTTP Response.\22},\22incoming-body\22:{\22docs\22:\22Represents an incoming HTTP Request or Response's Body.\5cn\5cnA body has both its contents - a stream of bytes - and a (possibly\5cnempty) set of trailers, indicating that the full contents of the\5cnbody have been received. This resource represents the contents as\5cnan `input-stream` and the delivery of trailers as a `future-trailers`,\5cnand ensures that the user of this interface may only be consuming either\5cnthe body contents or waiting on trailers at any given time.\22},\22future-trailers\22:{\22docs\22:\22Represents a future which may eventaully return trailers, or an error.\5cn\5cnIn the case that the incoming HTTP Request or Response did not have any\5cntrailers, this future will resolve to the empty set of trailers once the\5cncomplete Request or Response body has been received.\22},\22outgoing-response\22:{\22docs\22:\22Represents an outgoing HTTP Response.\22},\22outgoing-body\22:{\22docs\22:\22Represents an outgoing HTTP Request or Response's Body.\5cn\5cnA body has both its contents - a stream of bytes - and a (possibly\5cnempty) set of trailers, inducating the full contents of the body\5cnhave been sent. This resource represents the contents as an\5cn`output-stream` child resource, and the completion of the body (with\5cnoptional trailers) with a static function that consumes the\5cn`outgoing-body` resource, and ensures that the user of this interface\5cnmay not write to the body contents after the body has been finished.\5cn\5cnIf the user code drops this resource, as opposed to calling the static\5cnmethod `finish`, the implementation should treat the body as incomplete,\5cnand that an error has occured. The implementation should propogate this\5cnerror to the HTTP protocol by whatever means it has available,\5cnincluding: corrupting the body on the wire, aborting the associated\5cnRequest, or sending a late status code for the Response.\22},\22future-incoming-response\22:{\22docs\22:\22Represents a future which may eventaully return an incoming HTTP\5cnResponse, or an error.\5cn\5cnThis resource is returned by the `wasi:http/outgoing-handler` interface to\5cnprovide the HTTP Response corresponding to the sent Request.\22}}},\22incoming-handler\22:{\22docs\22:\22This interface defines a handler of incoming HTTP Requests. It should\5cnbe exported by components which can respond to HTTP Requests.\22,\22funcs\22:{\22handle\22:\22This function is invoked with an incoming HTTP Request, and a resource\5cn`response-outparam` which provides the capability to reply with an HTTP\5cnResponse. The response is sent by calling the `response-outparam.set`\5cnmethod, which allows execution to continue after the response has been\5cnsent. This enables both streaming to the response body, and performing other\5cnwork.\5cn\5cnThe implementor of this function must write a response to the\5cn`response-outparam` before returning, or else the caller will respond\5cnwith an error on its behalf.\22}},\22outgoing-handler\22:{\22docs\22:\22This interface defines a handler of outgoing HTTP Requests. It should be\5cnimported by components which wish to make HTTP Requests.\22,\22funcs\22:{\22handle\22:\22This function is invoked with an outgoing HTTP Request, and it returns\5cna resource `future-incoming-response` which represents an HTTP Response\5cnwhich may arrive in the future.\5cn\5cnThe `options` argument accepts optional parameters for the HTTP\5cnprotocol's transport layer.\5cn\5cnThis function may return an error if the `outgoing-request` is invalid\5cnor not allowed to be made. Otherwise, protocol errors are reported\5cnthrough the `future-incoming-response`.\22}}}}") (@producers (processed-by "wit-component" "$CARGO_PKG_VERSION") ) diff --git a/crates/wit-component/tests/interfaces/wasi-http/http.wit.print b/crates/wit-component/tests/interfaces/wasi-http/http.wit.print index ff5dd9b189..a6420bcb74 100644 --- a/crates/wit-component/tests/interfaces/wasi-http/http.wit.print +++ b/crates/wit-component/tests/interfaces/wasi-http/http.wit.print @@ -49,7 +49,7 @@ interface types { } /// These cases are inspired by the IANA HTTP Proxy Error Types: - /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types + /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types variant error-code { DNS-timeout, DNS-error(DNS-error-payload), diff --git a/crates/wit-parser/src/ast/resolve.rs b/crates/wit-parser/src/ast/resolve.rs index 1ce7cb71dd..b38d658866 100644 --- a/crates/wit-parser/src/ast/resolve.rs +++ b/crates/wit-parser/src/ast/resolve.rs @@ -1434,13 +1434,34 @@ impl<'a> Resolver<'a> { fn docs(&mut self, doc: &super::Docs<'_>) -> Docs { let mut docs = vec![]; + for doc in doc.docs.iter() { - if let Some(doc) = doc.strip_prefix("/**") { - docs.push(doc.strip_suffix("*/").unwrap().trim()); - } else { - docs.push(doc.trim_start_matches('/').trim()); - } + let contents = match doc.strip_prefix("/**") { + Some(doc) => doc.strip_suffix("*/").unwrap(), + None => doc.trim_start_matches('/'), + }; + + docs.push(contents.trim_end()); } + + // Scan the (non-empty) doc lines to find the minimum amount of leading whitespace. + // This amount of whitespace will be removed from the start of all doc lines, + // normalizing the output while retaining intentional spacing added by the original authors. + let min_leading_ws = docs + .iter() + .filter(|doc| !doc.is_empty()) + .map(|doc| doc.bytes().take_while(|c| c.is_ascii_whitespace()).count()) + .min() + .unwrap_or(0); + + if min_leading_ws > 0 { + let leading_ws_pattern = " ".repeat(min_leading_ws); + docs = docs + .iter() + .map(|doc| doc.strip_prefix(&leading_ws_pattern).unwrap_or(doc)) + .collect(); + } + let contents = if docs.is_empty() { None } else { diff --git a/crates/wit-parser/tests/ui/comments.wit.json b/crates/wit-parser/tests/ui/comments.wit.json index 7c7a44e1c4..b15b1200f7 100644 --- a/crates/wit-parser/tests/ui/comments.wit.json +++ b/crates/wit-parser/tests/ui/comments.wit.json @@ -9,7 +9,7 @@ }, "functions": {}, "docs": { - "contents": "hello\nworld\nwhy, yes\nthis is a comment\n* this too */\n* is a comment */\n* this /* is /* a */ nested */ comment */" + "contents": " hello\n world\n why, yes\n this is a comment\n* this too */\n* is a comment */\n* this /* is /* a */ nested */ comment */" }, "package": 0 } diff --git a/tests/cli.rs b/tests/cli.rs index 837a2f011d..d298670672 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -203,7 +203,7 @@ fn assert_output(bless: bool, output: &[u8], path: &Path, tempdir: &TempDir) -> // sanitize the output to be consistent across platforms and handle per-test // differences such as `%tmpdir`, as well as the version number of the crate being // tested in the producers custom section. - let output = String::from_utf8_lossy(output) + let mut output = String::from_utf8_lossy(output) .replace(tempdir, "%tmpdir") .replace("\\", "/") .lines() @@ -216,7 +216,14 @@ fn assert_output(bless: bool, output: &[u8], path: &Path, tempdir: &TempDir) -> } }) .collect::>() - .join("\n"); + .join("\n") + .trim_end() + .to_string(); + + // Leave a single trailing newline on all test outputs + if !output.is_empty() { + output.push_str("\n"); + } if bless { if output.is_empty() { @@ -234,13 +241,9 @@ fn assert_output(bless: bool, output: &[u8], path: &Path, tempdir: &TempDir) -> Ok(()) } } else { - let mut contents = std::fs::read_to_string(path) + let contents = std::fs::read_to_string(path) .with_context(|| format!("failed to read {path:?}"))? .replace("\r\n", "\n"); - // Drop any trailing newline, the lines iterator on output above will do the same - if contents.ends_with('\n') { - contents.pop(); - } if output != contents { bail!( "failed test: result is not as expected:{}", diff --git a/tests/cli/add-metadata-merge-sections.wat.stdout b/tests/cli/add-metadata-merge-sections.wat.stdout index accb94fc95..49ed566de7 100644 --- a/tests/cli/add-metadata-merge-sections.wat.stdout +++ b/tests/cli/add-metadata-merge-sections.wat.stdout @@ -12,4 +12,4 @@ │ language ┆ bar [1] │ ├╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤ │ sdk ┆ foo [2] │ -╰──────────┴───────────╯ \ No newline at end of file +╰──────────┴───────────╯ diff --git a/tests/cli/add-metadata-overwrite-name.wat.stdout b/tests/cli/add-metadata-overwrite-name.wat.stdout index e02f74d9b0..6803d701b0 100644 --- a/tests/cli/add-metadata-overwrite-name.wat.stdout +++ b/tests/cli/add-metadata-overwrite-name.wat.stdout @@ -6,4 +6,4 @@ │ name ┆ foo │ ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤ │ range ┆ 0x0..0x15 │ -╰───────┴───────────╯ \ No newline at end of file +╰───────┴───────────╯ diff --git a/tests/cli/add-metadata.wat.stdout b/tests/cli/add-metadata.wat.stdout index 3fa15ddc76..b83255d9a5 100644 --- a/tests/cli/add-metadata.wat.stdout +++ b/tests/cli/add-metadata.wat.stdout @@ -12,4 +12,4 @@ │ processed-by ┆ baz [1] │ ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ │ sdk ┆ my-sdk [2] │ -╰──────────────┴────────────╯ \ No newline at end of file +╰──────────────┴────────────╯ diff --git a/tests/cli/dump-dylink0.wat.stdout b/tests/cli/dump-dylink0.wat.stdout index ae6e2c7eb2..221ab824a2 100644 --- a/tests/cli/dump-dylink0.wat.stdout +++ b/tests/cli/dump-dylink0.wat.stdout @@ -13,4 +13,4 @@ 0x26 | 04 06 01 01 | ImportInfo([ImportInfo { module: "a", field: "a", flags: SymbolFlags(0x0) }]) | 61 01 61 00 0x2e | 03 04 01 01 | ExportInfo([ExportInfo { name: "a", flags: SymbolFlags(BINDING_WEAK | BINDING_LOCAL | UNDEFINED) }]) - | 61 13 + | 61 13 diff --git a/tests/cli/dump/bundled.wat.stdout b/tests/cli/dump/bundled.wat.stdout index 4408c98265..a2d5d6eae5 100644 --- a/tests/cli/dump/bundled.wat.stdout +++ b/tests/cli/dump/bundled.wat.stdout @@ -235,4 +235,4 @@ 0x25e | 01 | 1 count 0x25f | 00 09 72 65 | Naming { index: 0, name: "real-wasi" } | 61 6c 2d 77 - | 61 73 69 + | 61 73 69 diff --git a/tests/cli/dump/component-inline-export-import.wat.stdout b/tests/cli/dump/component-inline-export-import.wat.stdout index 3a51b4e51a..f29289865b 100644 --- a/tests/cli/dump/component-inline-export-import.wat.stdout +++ b/tests/cli/dump/component-inline-export-import.wat.stdout @@ -18,4 +18,4 @@ 0x25 | 00 00 04 00 | export ComponentExport { name: ComponentExportName(""), kind: Component, index: 0, ty: None } | 00 0x2a | 00 01 61 00 | export ComponentExport { name: ComponentExportName("a"), kind: Module, index: 0, ty: None } - | 11 00 00 + | 11 00 00 diff --git a/tests/cli/dump/component-inline-type.wat.stdout b/tests/cli/dump/component-inline-type.wat.stdout index 77917a712d..638b08b074 100644 --- a/tests/cli/dump/component-inline-type.wat.stdout +++ b/tests/cli/dump/component-inline-type.wat.stdout @@ -27,4 +27,4 @@ 0x37 | 0a 06 | component import section 0x39 | 01 | 1 count 0x3a | 00 01 64 01 | [func 0] ComponentImport { name: ComponentImportName("d"), ty: Func(2) } - | 02 + | 02 diff --git a/tests/cli/dump/component-instance-type.wat.stdout b/tests/cli/dump/component-instance-type.wat.stdout index 6b299f2bbb..7e5301b4f2 100644 --- a/tests/cli/dump/component-instance-type.wat.stdout +++ b/tests/cli/dump/component-instance-type.wat.stdout @@ -20,4 +20,4 @@ 0x43 | 01 09 03 | type name section 0x46 | 01 | 1 count 0x47 | 00 05 6f 75 | Naming { index: 0, name: "outer" } - | 74 65 72 + | 74 65 72 diff --git a/tests/cli/dump/instance-type.wat.stdout b/tests/cli/dump/instance-type.wat.stdout index 83ad5fbe2a..1dc2a5230f 100644 --- a/tests/cli/dump/instance-type.wat.stdout +++ b/tests/cli/dump/instance-type.wat.stdout @@ -7,4 +7,4 @@ | 00 00 01 00 0x17 | 42 02 01 42 | [type 1] Instance([Type(Instance([])), Export { name: ComponentExportName(""), ty: Instance(0) }]) | 00 04 00 00 - | 05 00 + | 05 00 diff --git a/tests/cli/dump/module-types.wat.stdout b/tests/cli/dump/module-types.wat.stdout index 46fe586c58..8a8c2d5b24 100644 --- a/tests/cli/dump/module-types.wat.stdout +++ b/tests/cli/dump/module-types.wat.stdout @@ -29,4 +29,4 @@ 0x54 | 01 09 03 | type name section 0x57 | 01 | 1 count 0x58 | 00 05 65 6d | Naming { index: 0, name: "empty" } - | 70 74 79 + | 70 74 79 diff --git a/tests/cli/dump/nested-component.wat.stdout b/tests/cli/dump/nested-component.wat.stdout index abb57173e8..ec185c19b8 100644 --- a/tests/cli/dump/nested-component.wat.stdout +++ b/tests/cli/dump/nested-component.wat.stdout @@ -70,4 +70,4 @@ 0xbc | 0b 07 | component export section 0xbe | 01 | 1 count 0xbf | 00 01 61 04 | export ComponentExport { name: ComponentExportName("a"), kind: Component, index: 3, ty: None } - | 03 00 + | 03 00 diff --git a/tests/cli/importize.wit.simple-rename.stdout b/tests/cli/importize.wit.simple-rename.stdout index b921e7e2fc..64612e20a9 100644 --- a/tests/cli/importize.wit.simple-rename.stdout +++ b/tests/cli/importize.wit.simple-rename.stdout @@ -1,7 +1,7 @@ /// RUN[simple]: component wit --importize-world simple % /// RUN[simple-rename]: component wit --importize-world simple-rename --importize-out-world-name test-rename % /// RUN[simple-component]: component embed --dummy --world simple % | / -/// component wit --importize +/// component wit --importize /// RUN[with-deps]: component wit --importize-world with-deps % /// RUN[simple-toplevel]: component wit --importize-world simple-toplevel % /// RUN[toplevel-deps]: component wit --importize-world toplevel-deps % diff --git a/tests/cli/importize.wit.simple-toplevel.stdout b/tests/cli/importize.wit.simple-toplevel.stdout index 7c79702db0..10aff4d972 100644 --- a/tests/cli/importize.wit.simple-toplevel.stdout +++ b/tests/cli/importize.wit.simple-toplevel.stdout @@ -1,7 +1,7 @@ /// RUN[simple]: component wit --importize-world simple % /// RUN[simple-rename]: component wit --importize-world simple-rename --importize-out-world-name test-rename % /// RUN[simple-component]: component embed --dummy --world simple % | / -/// component wit --importize +/// component wit --importize /// RUN[with-deps]: component wit --importize-world with-deps % /// RUN[simple-toplevel]: component wit --importize-world simple-toplevel % /// RUN[toplevel-deps]: component wit --importize-world toplevel-deps % diff --git a/tests/cli/importize.wit.simple.stdout b/tests/cli/importize.wit.simple.stdout index 80547c60e1..1bdb5c80b9 100644 --- a/tests/cli/importize.wit.simple.stdout +++ b/tests/cli/importize.wit.simple.stdout @@ -1,7 +1,7 @@ /// RUN[simple]: component wit --importize-world simple % /// RUN[simple-rename]: component wit --importize-world simple-rename --importize-out-world-name test-rename % /// RUN[simple-component]: component embed --dummy --world simple % | / -/// component wit --importize +/// component wit --importize /// RUN[with-deps]: component wit --importize-world with-deps % /// RUN[simple-toplevel]: component wit --importize-world simple-toplevel % /// RUN[toplevel-deps]: component wit --importize-world toplevel-deps % diff --git a/tests/cli/importize.wit.toplevel-deps.stdout b/tests/cli/importize.wit.toplevel-deps.stdout index 17b1c0e3f8..e187bd0607 100644 --- a/tests/cli/importize.wit.toplevel-deps.stdout +++ b/tests/cli/importize.wit.toplevel-deps.stdout @@ -1,7 +1,7 @@ /// RUN[simple]: component wit --importize-world simple % /// RUN[simple-rename]: component wit --importize-world simple-rename --importize-out-world-name test-rename % /// RUN[simple-component]: component embed --dummy --world simple % | / -/// component wit --importize +/// component wit --importize /// RUN[with-deps]: component wit --importize-world with-deps % /// RUN[simple-toplevel]: component wit --importize-world simple-toplevel % /// RUN[toplevel-deps]: component wit --importize-world toplevel-deps % diff --git a/tests/cli/importize.wit.tricky-import.stdout b/tests/cli/importize.wit.tricky-import.stdout index f5cb951cc7..08d2d5630a 100644 --- a/tests/cli/importize.wit.tricky-import.stdout +++ b/tests/cli/importize.wit.tricky-import.stdout @@ -1,7 +1,7 @@ /// RUN[simple]: component wit --importize-world simple % /// RUN[simple-rename]: component wit --importize-world simple-rename --importize-out-world-name test-rename % /// RUN[simple-component]: component embed --dummy --world simple % | / -/// component wit --importize +/// component wit --importize /// RUN[with-deps]: component wit --importize-world with-deps % /// RUN[simple-toplevel]: component wit --importize-world simple-toplevel % /// RUN[toplevel-deps]: component wit --importize-world toplevel-deps % diff --git a/tests/cli/importize.wit.trim-imports.stdout b/tests/cli/importize.wit.trim-imports.stdout index a0539ef9c9..831fce9705 100644 --- a/tests/cli/importize.wit.trim-imports.stdout +++ b/tests/cli/importize.wit.trim-imports.stdout @@ -1,7 +1,7 @@ /// RUN[simple]: component wit --importize-world simple % /// RUN[simple-rename]: component wit --importize-world simple-rename --importize-out-world-name test-rename % /// RUN[simple-component]: component embed --dummy --world simple % | / -/// component wit --importize +/// component wit --importize /// RUN[with-deps]: component wit --importize-world with-deps % /// RUN[simple-toplevel]: component wit --importize-world simple-toplevel % /// RUN[toplevel-deps]: component wit --importize-world toplevel-deps % diff --git a/tests/cli/importize.wit.with-deps.stdout b/tests/cli/importize.wit.with-deps.stdout index 1a48a0298e..9b567ad3ac 100644 --- a/tests/cli/importize.wit.with-deps.stdout +++ b/tests/cli/importize.wit.with-deps.stdout @@ -1,7 +1,7 @@ /// RUN[simple]: component wit --importize-world simple % /// RUN[simple-rename]: component wit --importize-world simple-rename --importize-out-world-name test-rename % /// RUN[simple-component]: component embed --dummy --world simple % | / -/// component wit --importize +/// component wit --importize /// RUN[with-deps]: component wit --importize-world with-deps % /// RUN[simple-toplevel]: component wit --importize-world simple-toplevel % /// RUN[toplevel-deps]: component wit --importize-world toplevel-deps % diff --git a/tests/cli/metadata-add-component.wat.stdout b/tests/cli/metadata-add-component.wat.stdout index bc4c6875e7..72c0673740 100644 --- a/tests/cli/metadata-add-component.wat.stdout +++ b/tests/cli/metadata-add-component.wat.stdout @@ -17,4 +17,4 @@ │ name ┆ │ ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤ │ range ┆ 0xa..0x31 │ -╰───────┴───────────╯ \ No newline at end of file +╰───────┴───────────╯ diff --git a/tests/cli/metadata-component.wat.stdout b/tests/cli/metadata-component.wat.stdout index dc109a55cf..d262ff852d 100644 --- a/tests/cli/metadata-component.wat.stdout +++ b/tests/cli/metadata-component.wat.stdout @@ -24,4 +24,4 @@ │ name ┆ another submodule │ ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ │ range ┆ 0x27..0x4a │ -╰───────┴───────────────────╯ \ No newline at end of file +╰───────┴───────────────────╯ diff --git a/tests/cli/metadata.wat.stdout b/tests/cli/metadata.wat.stdout index b255f9ff31..9dc357ab5c 100644 --- a/tests/cli/metadata.wat.stdout +++ b/tests/cli/metadata.wat.stdout @@ -6,4 +6,4 @@ │ name ┆ │ ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤ │ range ┆ 0x0..0x8 │ -╰───────┴───────────╯ \ No newline at end of file +╰───────┴───────────╯ diff --git a/tests/cli/print-code-section-overflow.wat.stdout b/tests/cli/print-code-section-overflow.wat.stdout index 356532d63f..b55cecc0af 100644 --- a/tests/cli/print-code-section-overflow.wat.stdout +++ b/tests/cli/print-code-section-overflow.wat.stdout @@ -1 +1 @@ -(module \ No newline at end of file +(module diff --git a/tests/cli/print-custom-indent-width.wat.stdout b/tests/cli/print-custom-indent-width.wat.stdout index 11b324786b..f09d0da02d 100644 --- a/tests/cli/print-custom-indent-width.wat.stdout +++ b/tests/cli/print-custom-indent-width.wat.stdout @@ -4,4 +4,4 @@ (func (;0;) (type 0) (param i32) (result i32) local.get 0 ) -) \ No newline at end of file +) diff --git a/tests/cli/print-dont-reserve-the-world.wat.stdout b/tests/cli/print-dont-reserve-the-world.wat.stdout index 356532d63f..b55cecc0af 100644 --- a/tests/cli/print-dont-reserve-the-world.wat.stdout +++ b/tests/cli/print-dont-reserve-the-world.wat.stdout @@ -1 +1 @@ -(module \ No newline at end of file +(module diff --git a/tests/cli/print-locals-overflow.wat.stdout b/tests/cli/print-locals-overflow.wat.stdout index 564f603c03..5af803de5c 100644 --- a/tests/cli/print-locals-overflow.wat.stdout +++ b/tests/cli/print-locals-overflow.wat.stdout @@ -1,3 +1,3 @@ (module (type (;0;) (func)) - (func (;0;) (type 0) \ No newline at end of file + (func (;0;) (type 0) diff --git a/tests/cli/print-memarg-too-big.wat.stdout b/tests/cli/print-memarg-too-big.wat.stdout index ef9290ef1c..06ed489ae5 100644 --- a/tests/cli/print-memarg-too-big.wat.stdout +++ b/tests/cli/print-memarg-too-big.wat.stdout @@ -1,2 +1,2 @@ (module - (data (;0;) (i32.load16_s \ No newline at end of file + (data (;0;) (i32.load16_s diff --git a/tests/cli/unbundle-print-module.wat.gen.stdout b/tests/cli/unbundle-print-module.wat.gen.stdout index bb8224cebd..4494db79de 100644 Binary files a/tests/cli/unbundle-print-module.wat.gen.stdout and b/tests/cli/unbundle-print-module.wat.gen.stdout differ diff --git a/tests/cli/wat2wasm-alias.wat.stdout b/tests/cli/wat2wasm-alias.wat.stdout index 357f72da7a..2a17087a75 100644 Binary files a/tests/cli/wat2wasm-alias.wat.stdout and b/tests/cli/wat2wasm-alias.wat.stdout differ diff --git a/tests/cli/wit-with-all-features.wit.stdout b/tests/cli/wit-with-all-features.wit.stdout index a193ef7786..05b7c7fec7 100644 --- a/tests/cli/wit-with-all-features.wit.stdout +++ b/tests/cli/wit-with-all-features.wit.stdout @@ -17,4 +17,3 @@ interface bar { y: t, } } -