-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into tsuf/limit-apis-amounts-in-tests
- Loading branch information
Showing
77 changed files
with
2,616 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -820,6 +820,9 @@ | |
"initial": { | ||
"tf-aws": { | ||
"implemented": true | ||
}, | ||
"sim": { | ||
"implemented": true | ||
} | ||
} | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: Debugging | ||
id: Debugging | ||
description: Learn how to debug your Wing application | ||
keywords: [debugging, debug, test, vscode] | ||
--- | ||
|
||
## Overview | ||
|
||
Internally Wing uses JavaScript to execute preflight and inflight code, so standard JavaScript debugging tools can be used to debug your Wing application. The best-supported debugger is the built-in VS Code one so this guide will focus on that. | ||
|
||
### Local/Simulator Debugging | ||
|
||
To start, open your .w file in VS Code and set a breakpoint by clicking in the gutter to the left of the line number. Breakpoints can also be set in extern files. There are several ways to start the debugger, but let's use the "JavaScript Debug Terminal". | ||
Open the command palette and type "Debug: Open JavaScript Debug Terminal". This works for any wing commands like `wing test` and `wing it`, although keep in mind that `wing compile` will only debug preflight code. | ||
|
||
### Limitations | ||
|
||
- ([Issue](https://github.com/winglang/wing/issues/5988)) When using the Wing Console (`wing it`) and attempting to debug inflight code in a `test` or Function, the first execution of the test will not hit a breakpoint and will need to be run again | ||
- ([Issue](https://github.com/winglang/wing/issues/5986)) inflight code by default has a timeout that continues during debugging, so if execution is paused for too long the program is terminate | ||
- Caught/Unhandled will often not stop at expected places | ||
|
||
#### Non-VSCode Support | ||
|
||
The Wing CLI itself is a Node.js application, so you can use the `--inspect` flag to debug it and expose a debug server. | ||
|
||
```bash | ||
node --inspect $(which wing) | ||
``` | ||
|
||
Note that inflight code will be executed among multiple child processes, so it's recommended to use a debugger that supports automatically attaching to child processes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
bring cloud; | ||
|
||
let bucket = new cloud.Bucket(); | ||
|
||
let prelight_string = "hi"; | ||
|
||
class Foo { | ||
pub inflight mehtod1() { | ||
let b = bucket; | ||
lift(b, ["put"]); // Explicit qualification with inflight object, lift call as non first statement | ||
// ^ Expected a preflight object as first argument to `lift` builtin, found inflight expression instead | ||
//^^^^^^^^^^^^^^^ lift() calls must be at the top of the method | ||
|
||
lift(prelight_string, ["contains"]); // Explicit qualification on preflight non-class | ||
// ^^^^^^^^^^^^^^^ Expected type to be "Resource", but got "str" instead | ||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lift() calls must be at the top of the method | ||
|
||
let inflight_qualifier = "delete"; | ||
lift(bucket, [inflight_qualifier]); // Explicit qualification with inflight qualifiers, lift call as non first statement | ||
// ^^^^^^^^^^^^^^^^^^^^ Qualification list must not contain any inflight elements | ||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lift() calls must be at the top of the method | ||
|
||
let inner_closure = () => { | ||
lift(bucket, ["get"]); // lift() call in inner closure | ||
//^^^^^^^^^^^^^^^^^^^^ lift() calls are only allowed in inflight methods and closures defined in preflight | ||
}; | ||
class Bar { | ||
pub inflight method() { | ||
lift(bucket, ["get"]); // lift() call in inner class | ||
//^^^^^^^^^^^^^^^^^^^^ lift() calls are only allowed in inflight methods and closures defined in preflight | ||
} | ||
} | ||
} | ||
|
||
pub inflight method2() { | ||
let b = bucket; | ||
b.put("k", "v"); // With no explicit qualification this should be an error | ||
//^ Expression of type "Bucket" references an unknown preflight object | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
bring cloud; | ||
|
||
let bucket = new cloud.Bucket(); | ||
bucket.addObject("k", "value"); | ||
|
||
let put_and_list = ["put", "list"]; | ||
|
||
class Foo { | ||
pub inflight mehtod() { | ||
lift(bucket, put_and_list); // Qualify `bucket` with a preflight expression | ||
lift(bucket, ["delete"]); // Qualify `bucket` with `delete` via literal | ||
let b = bucket; // Assign `bucket` to an inflight variable | ||
|
||
// `put` should work on `b` since we explicitly qualified `bucket` with `put` | ||
// no error generated here because of use of `lift()` in this method | ||
b.put("k2", "value2"); | ||
|
||
// validate `put` worked and that we can also `list` | ||
assert(b.list() == ["k", "k2"]); | ||
|
||
// Validate `delete` works | ||
b.delete("k2"); | ||
assert(bucket.tryGet("k2") == nil); | ||
} | ||
} | ||
|
||
let foo = new Foo(); | ||
|
||
test "explicit method lift qualification" { | ||
foo.mehtod(); | ||
} | ||
|
||
// Similar to the above test, but using a closure | ||
let inflight_closure = inflight () => { | ||
lift(bucket, ["put"]); | ||
let b = bucket; | ||
b.put("k3", "value3"); // Use inflight expression to access explicitly qualified `bucket` | ||
assert(bucket.get("k3") == "value3"); | ||
}; | ||
|
||
test "explicit closure lift qualification" { | ||
inflight_closure(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.