Skip to content

Commit

Permalink
update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriscbr committed Sep 24, 2024
1 parent 54d78cc commit d47747d
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 15 deletions.
1 change: 1 addition & 0 deletions docs/api/05-language-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ the following properties (given an example intrinsic `@x`):
| `@assert()` | checks a condition and _throws_ if evaluated to false |
| `@filename` | absolute path of the source file |
| `@dirname` | absolute path of the source file's directory |
| `@target` | a string identifying the current target platform |
| `@app` | the root of the construct tree |
| `@unsafeCast()` | cast a value into a different type |
| `@nodeof()` | obtain the [tree node](/docs/concepts/application-tree) of a preflight object |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ source: packages/@winglang/wingc/src/lsp/completions.rs
kind: markdown
value: "Get the normalized absolute path of the current Wing source file.\n\nThe resolved path represents a path during preflight only and is not guaranteed to be valid while inflight."
sortText: bb|@filename
- label: "@target"
kind: 6
detail: str
documentation:
kind: markdown
value: "Returns a string identifying the current compilation platform.\n\nThis value is set by the CLI at compile time and can be used to conditionally compile code that is dependent on the target platform."
sortText: bb|@target

Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ source: packages/@winglang/wingc/src/lsp/completions.rs
kind: markdown
value: "Get the normalized absolute path of the current Wing source file.\n\nThe resolved path represents a path during preflight only and is not guaranteed to be valid while inflight."
sortText: bb|@filename
- label: "@target"
kind: 6
detail: str
documentation:
kind: markdown
value: "Returns a string identifying the current compilation platform.\n\nThis value is set by the CLI at compile time and can be used to conditionally compile code that is dependent on the target platform."
sortText: bb|@target

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
## stdout.log
```log
[ERROR] method calls fail if the resource fails to start | Error: unexpected error!
--> on-start.test.w:6:5
--> on-start.test.w:5:5
|
| inflight class OnStartThrowerBackend impl sim.IResource {
| new() {
6 | throw "unexpected error!";
5 | throw "unexpected error!";
| ^
at $inflight_init <ABSOLUTE>/on-start.test.w:6:5
at <ABSOLUTE>/on-start.test.w:17:18
at $inflight_init <ABSOLUTE>/on-start.test.w:5:5
at <ABSOLUTE>/on-start.test.w:16:18
[ERROR] method calls fail if the resource fails to start | Error: root/Default/OnStartThrower/Resource failed to start: Error: unexpected error!
[ERROR] method calls fail if the resource fails to start | Error: Resource is not running (it may have crashed or stopped)
pass ─ on-start.test.wsim » root/Default/test:method calls fail if the resource fails to start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
## stdout.log
```log
[ERROR] if a resource throws an error on stopping, it doesn't crash the simulation | Error: unexpected error!
--> on-stop.test.w:6:5
--> on-stop.test.w:5:5
|
| inflight class OnStopThrowerBackend impl sim.IResource {
| pub onStop() {
6 | throw "unexpected error!";
5 | throw "unexpected error!";
| ^
at onStop <ABSOLUTE>/on-stop.test.w:6:5
at onStop <ABSOLUTE>/on-stop.test.w:5:5
pass ─ on-stop.test.wsim » root/Default/test:if a resource throws an error on stopping, it doesn't crash the simulation
Tests 1 passed (1)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# [init.test.w](../../../../../../tests/sdk_tests/schedule/init.test.w) | compile | tf-aws

## main.tf.json
```json
{
"//": {
"metadata": {
"backend": "local",
"stackName": "root"
},
"outputs": {}
},
"provider": {
"aws": [
{}
]
},
"resource": {
"aws_cloudwatch_event_rule": {
"s0_Schedule_7FE1E150": {
"//": {
"metadata": {
"path": "root/Default/Default/s0/Schedule",
"uniqueId": "s0_Schedule_7FE1E150"
}
},
"schedule_expression": "rate(5 minutes)"
}
}
}
}
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# [init.test.w](../../../../../../tests/sdk_tests/schedule/init.test.w) | test | sim

## stdout.log
```log
pass ─ init.test.wsim (no tests)
Tests 1 passed (1)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
```

Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ class $Root extends $stdlib.std.Resource {
$helpers.nodeof(this).root.$preflightTypesMap = { };
let $preflightTypesMap = {};
const cloud = $stdlib.cloud;
const util = $stdlib.util;
const aws = require("@cdktf/provider-aws");
$helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap;
const b = globalThis.$ClassFactory.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "Bucket");
if ($helpers.eq((util.Util.env("WING_TARGET")), "tf-aws")) {
if ($helpers.eq(process.env.WING_TARGET, "tf-aws")) {
const s3Bucket = ($helpers.nodeof(b).findChild("Default"));
(s3Bucket.addOverride("bucket_prefix", "my-prefix-"));
console.log($helpers.nodeof(s3Bucket).path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = function({ $foo }) {
"use strict";
const $helpers = require("@winglang/sdk/lib/helpers");
const $macros = require("@winglang/sdk/lib/macros");
module.exports = function({ $expect_Util, $fn, $fn2, $sim }) {
module.exports = function({ $expect_Util, $fn, $fn2 }) {
class $Closure3 {
constructor($args) {
const { } = $args;
Expand All @@ -64,7 +64,7 @@ module.exports = function({ $expect_Util, $fn, $fn2, $sim }) {
const y = (await $fn.invoke(""));
const z = (await $fn2.invoke(""));
(await $expect_Util.equal(x, "100"));
if ($sim) {
if ($helpers.eq(process.env.WING_TARGET, "sim")) {
(await $expect_Util.equal(y, "101"));
console.log("client has been reused");
}
Expand Down Expand Up @@ -546,7 +546,6 @@ class $Root extends $stdlib.std.Resource {
$expect_Util: ${$stdlib.core.liftObject($stdlib.core.toLiftableModuleType(globalThis.$ClassFactory.resolveType("@winglang/sdk.expect.Util") ?? expect.Util, "@winglang/sdk/expect", "Util"))},
$fn: ${$stdlib.core.liftObject(fn)},
$fn2: ${$stdlib.core.liftObject(fn2)},
$sim: ${$stdlib.core.liftObject(sim)},
})
`;
}
Expand All @@ -556,13 +555,11 @@ class $Root extends $stdlib.std.Resource {
[$stdlib.core.toLiftableModuleType(globalThis.$ClassFactory.resolveType("@winglang/sdk.expect.Util") ?? expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]],
[fn, ["invoke"]],
[fn2, ["invoke"]],
[sim, []],
],
"$inflight_init": [
[$stdlib.core.toLiftableModuleType(globalThis.$ClassFactory.resolveType("@winglang/sdk.expect.Util") ?? expect.Util, "@winglang/sdk/expect", "Util"), []],
[fn, []],
[fn2, []],
[sim, []],
],
});
}
Expand Down Expand Up @@ -630,7 +627,6 @@ class $Root extends $stdlib.std.Resource {
const foo = new Foo(this, "Foo");
const fn = globalThis.$ClassFactory.new("@winglang/sdk.cloud.Function", cloud.Function, this, "Function", new $Closure1(this, "$Closure1"));
const fn2 = globalThis.$ClassFactory.new("@winglang/sdk.cloud.Function", cloud.Function, this, "fn2", new $Closure2(this, "$Closure2"));
const sim = $helpers.eq((util.Util.env("WING_TARGET")), "sim");
globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:single instance of Foo", new $Closure3(this, "$Closure3"));
const fn3 = globalThis.$ClassFactory.new("@winglang/sdk.cloud.Function", cloud.Function, this, "fn3", new $Closure4(this, "$Closure4"));
globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:Foo state is not shared between function invocations", new $Closure5(this, "$Closure5"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class $Root extends $stdlib.std.Resource {
(expect.Util.equal($helpers.resolve(__dirname, "../../../intrinsics.test.w"), currentFile));
(expect.Util.equal((fs.Util.dirname(currentFile)), $helpers.resolve(__dirname, "../../..")));
(expect.Util.equal((bar.Bar.getSubfile(this)), (fs.Util.join($helpers.resolve(__dirname, "../../.."), "subdir", "bar.w"))));
(expect.Util.ok($macros.__Array_contains(false, ["sim", "tf-aws", "tf-azure", "tf-gcp", "awscdk"], process.env.WING_TARGET)));
}
}
const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "intrinsics.test", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] });
Expand Down

0 comments on commit d47747d

Please sign in to comment.