Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestCase is not supported in semantic analysis #403

Closed
onelson opened this issue Feb 16, 2022 · 2 comments · Fixed by influxdata/flux#4566 or influxdata/flux#5086
Closed

TestCase is not supported in semantic analysis #403

onelson opened this issue Feb 16, 2022 · 2 comments · Fixed by influxdata/flux#4566 or influxdata/flux#5086

Comments

@onelson
Copy link
Contributor

onelson commented Feb 16, 2022

When using the CLI lang server with IntelliJ, testcases are rendered as errors.

image

For this instance, I was looking at stdlib/array/array_test.flux in the flux repo.
Here's the log output from the lang server:

[Trace - 10:52:12 AM] Sending notification 'textDocument/didChange'
Params: {
  "textDocument": {
    "version": 2,
    "uri": "file:///home/onelson/Projects/flux/stdlib/array/array_test.flux"
  },
  "contentChanges": [
    {
      "text": "package array_test\n\n\nimport \"testing\"\nimport \"array\"\n\nfromElement \u003d (v) \u003d\u003e array.from(rows: [{v: v}])\n\ntestcase fromElementTest {\n    want \u003d fromElement(v: 123)\n    got \u003d fromElemen
t(v: 123)\n\n    testing.diff(want, got)\n        |\u003e yield()\n}\n"
    }
  ]
}


[Trace - 10:52:12 AM] Received notification 'textDocument/publishDiagnostics'
Params: {
  "uri": "file:///home/onelson/Projects/flux/stdlib/array/array_test.flux",
  "diagnostics": [
    {
      "range": {
        "start": {
          "line": 8,
          "character": 0
        },
        "end": {
          "line": 14,
          "character": 1
        }
      },
      "severity": 1,
      "source": "flux",
      "message": "TestCase is not supported in semantic analysis"
    }
  ]
}
@onelson
Copy link
Contributor Author

onelson commented Feb 16, 2022

Coincidentally, this has the same treatment in vscode. It wasn't unexpected, but I didn't want to assume...
Screenshot_20220216_114937

@nathanielc
Copy link
Contributor

I get this too, in short the test harness rewrites testcase AST into other AST statements removing the testcase statement. As a result semantic analysis doesn't know how to handle testcase statements.

nathanielc added a commit to influxdata/flux that referenced this issue Mar 16, 2022
Now the AST -> Semantic convert step does not error on testcase
statements, rather an explicit semantic check is used to catch remaining
testcase statements. The TestCase semantic node behaves like a partial
file where it has a statement list instead of a block. A block is an
expression that evaluates to a value which is not appropriate for a
testcase.

Fixes influxdata/flux-lsp#403 because the LSP
already skips semantic checks and so it doesn't report a diagnostic
about a testcase statement.
nathanielc added a commit to influxdata/flux that referenced this issue Mar 16, 2022
Now the AST -> Semantic convert step does not error on testcase
statements, rather an explicit semantic check is used to catch remaining
testcase statements. The TestCase semantic node behaves like a partial
file where it has a statement list instead of a block. A block is an
expression that evaluates to a value which is not appropriate for a
testcase.

Fixes influxdata/flux-lsp#403 because the LSP
already skips semantic checks and so it doesn't report a diagnostic
about a testcase statement.
nathanielc added a commit to influxdata/flux that referenced this issue Mar 16, 2022
Now the AST -> Semantic convert step does not error on testcase
statements, rather an explicit semantic check is used to catch remaining
testcase statements. The TestCase semantic node behaves like a partial
file where it has a statement list instead of a block. A block is an
expression that evaluates to a value which is not appropriate for a
testcase.

Fixes influxdata/flux-lsp#403 because the LSP
already skips semantic checks and so it doesn't report a diagnostic
about a testcase statement.
nathanielc added a commit to influxdata/flux that referenced this issue Mar 17, 2022
…4566)

Now the AST -> Semantic convert step does not error on testcase
statements, rather an explicit semantic check is used to catch remaining
testcase statements. The TestCase semantic node behaves like a partial
file where it has a statement list instead of a block. A block is an
expression that evaluates to a value which is not appropriate for a
testcase.

Fixes influxdata/flux-lsp#403 because the LSP
already skips semantic checks and so it doesn't report a diagnostic
about a testcase statement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants