Commit Graph

12 Commits

Author SHA1 Message Date
Abhinav Gupta 9d944a4a1f
test(codegen/go): Fix broken TestLiteralExpression
TestLiteralExpression appears to be broken on master:

```
% go test -run TestLiteralExpression
--- FAIL: TestLiteralExpression (0.00s)
    --- FAIL: TestLiteralExpression/"foo_${bar}_%baz" (0.05s)
        gen_program_expression_test.go:252:
                Error Trace:    [..]/pulumi/pkg/codegen/go/gen_program_expression_test.go:252
                Error:          Not equal:
                                expected: "fmt.Sprintf(\"foo %v %vbaz\", bar, \"%\")"
                                actual  : "fmt.Sprintf(\"foo %v%v\", bar, \" %baz\")"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -fmt.Sprintf("foo %v %vbaz", bar, "%")
                                +fmt.Sprintf("foo %v%v", bar, " %baz")
                Test:           TestLiteralExpression/"foo_${bar}_%baz"
```

Both versions are a valid way to represent that information,
so I'm fixing the test case.

I'm not sure how this broken test ended on master, though.
2023-06-20 12:25:42 -07:00
Abhinav Gupta 0bff0b8716 sdk/go: Remove 'nolint' directives from package docs
Go treats comments that match the following regex as directives.

    //[a-z0-9]+:[a-z0-9]

Comments that are directives don't show in an entity's documentation.
5a550b6951 (diff-f56160fd9fcea272966a8a1d692ad9f49206fdd8dbcbfe384865a98cd9bc2749R165)

Our code has `//nolint` directives that now show in the API Reference.
This is because these directives are in one of the following forms,
which don't get this special treatment.

    // nolint:foo
    //nolint: foo

This change fixes all such directives found by the regex:
`// nolint|//nolint: `.
See bottom of commit for command used for the fix.

Verification:
Here's the output of `go doc` on some entities
before and after this change.

Before
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi | head -n8
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

nolint: lll, interfacer

nolint: lll, interfacer

const EnvOrganization = "PULUMI_ORGANIZATION" ...
var ErrPlugins = errors.New("pulumi: plugins requested")
```

After
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi | head -n8
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

const EnvOrganization = "PULUMI_ORGANIZATION" ...
var ErrPlugins = errors.New("pulumi: plugins requested")
func BoolRef(v bool) *bool
func Float64Ref(v float64) *float64
func IntRef(v int) *int
func IsSecret(o Output) bool
```

Before
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi URN_
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

func URN_(o string) ResourceOption
    URN_ is an optional URN of a previously-registered resource of this type to
    read from the engine. nolint: revive
```

After:
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi URN_
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

func URN_(o string) ResourceOption
    URN_ is an optional URN of a previously-registered resource of this type to
    read from the engine.
```

Note that golangci-lint offers a 'nolintlint'  linter
that finds such miuses of nolint,
but it also finds other issues so I've deferred that to a follow up PR.

Resolves 

Related: https://github.com/golangci/golangci-lint/issues/892

[git-generate]
FILES=$(mktemp)
rg -l '// nolint|//nolint: ' |
  tee "$FILES" |
  xargs perl -p -i -e '
    s|// nolint|//nolint|g;
    s|//nolint: |//nolint:|g;
  '
rg '.go$' < "$FILES" | xargs gofmt -w -s
2023-01-06 09:06:47 -08:00
Ian Wahbe 633d586aeb
Handle long traversals in a nicer way ()
* Handle long traversals in a nicer way

* CL

* assert no error

* Update tests
2022-06-02 09:36:33 -07:00
Aaron Friel ed2923653c ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
Ian Wahbe 9f6589ed8c
iwahbe/7802/compile program generator test output ()
* Move program tests into folders

* update package schema

* Enabled tests pass

* Fix lints and begin to update test cases

* Re-enable tests

* Update aws version to v4

* Refactor language specific parts

* Hook up dotnet and nodejs

* Update tests from master

* SSOT for schema/version

* Name blocking errors. Leave tests in valid state

* Give each language its own folder

* Remove SkipCompile for azure-sa (bug was fixed)

* Fix nits + changes asserts to require

* Remove unused import

* One last assert => require
2021-09-29 11:33:57 -07:00
Pat Gavlin 7b1d6ec1ac
Reify `Input` and `Optional` types in the schema type system. ()
These changes support arbitrary combinations of input + plain types
within a schema. Handling plain types at the property level was not
sufficient to support such combinations. Reifying these types
required updating quite a bit of code. This is likely to have caused
some temporary complications, but should eventually lead to
substantial simplification in the SDK and program code generators.

With the new design, input and optional types are explicit in the schema
type system. Optionals will only appear at the outermost level of a type
(i.e. Input<Optional<>>, Array<Optional<>>, etc. will not occur). In
addition to explicit input types, each object type now has a "plain"
shape and an "input" shape. The former uses only plain types; the latter
uses input shapes wherever a plain type is not specified. Plain types
are indicated in the schema by setting the "plain" property of a type spec
to true.
2021-06-24 09:17:55 -07:00
pulumi-bot 73a66f48ea [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
Mikhail Shilkov 98f04cd2fc
Ensure top-level precedence to avoid flaky tests () 2020-10-05 19:50:51 +02:00
Evan Boyle fa3000801e
skip transient test () 2020-06-24 13:53:18 -07:00
Evan Boyle 94cd67b564
[Go Program Gen] Improved type handling and invokes () 2020-06-05 18:52:00 -07:00
Evan Boyle 9b2c6d726d
[Go Program Gen] binary, unary, and conditional expression support () 2020-05-28 13:47:49 -07:00
Evan Boyle c8142677cc
expression tests for basic go program literals () 2020-05-27 07:32:13 -07:00