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

Dynamic tests #5947

Open
meirdev opened this issue Mar 14, 2024 · 4 comments
Open

Dynamic tests #5947

meirdev opened this issue Mar 14, 2024 · 4 comments
Labels
✨ enhancement New feature or request 📐 language-design Language architecture needs-discussion Further discussion is needed prior to impl 🧪 testing

Comments

@meirdev
Copy link
Contributor

meirdev commented Mar 14, 2024

I tried this:

let tests: Map<inflight (): str> = {
  "foo": inflight () => { return "..."; },
  "bar": inflight () => { return "..."; },
};

let runTest = (key: str) => {
  test "{key}" {
    log("do something...");
  }
};

for test_ in Json.keys(tests) {
  runTest(test_);
}

This happened:

An error has occurred:
Failed to compile.

Error: There is already a Construct with name 'test:{key}' in $Root [Default]

hint: Every preflight object needs a unique identifier within its scope. You can assign one as shown:

> new cloud.Bucket() as "MyBucket";

For more information, see https://www.winglang.io/docs/concepts/application-tree
  --> foo.main.w:7:3
  | };
  | 
  | let runTest = (key: str) => {
7 |   test "{key}" {
  |   ^

I expected this:

No response

Is there a workaround?

No response

Anything else?

With one test:

...

runTest("foo");

The code is compiled but cannot run:

Screenshot 2024-03-14 at 14 29 14

My use case is to run the same tests across many classes with the same interface.

Wing Version

0.59.46

Node.js Version

v20.11.0

Platform(s)

MacOS

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
@meirdev meirdev added the 🐛 bug Something isn't working label Mar 14, 2024
@monadabot monadabot added this to Wing Mar 14, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New - not properly defined in Wing Mar 14, 2024
@MarkMcCulloh
Copy link
Contributor

A workaround (use std.Test):

let tests: Map<inflight (): str> = {
  "foo": inflight () => { return "..."; },
  "bar": inflight () => { return "..."; },
};

let runTest = (key: str) => {
  new std.Test(inflight () => {
    log("do something...");
  }) as "{key}";
};

for test_ in Json.keys(tests) {
  runTest(test_);
}

would be nice to allow interpolations for test "" {} declarations though

@meirdev
Copy link
Contributor Author

meirdev commented Mar 14, 2024

@MarkMcCulloh Thanks! 🙏

@staycoolcall911 staycoolcall911 moved this from 🆕 New - not properly defined to 🤝 Backlog - handoff to owners in Wing Mar 20, 2024
@staycoolcall911 staycoolcall911 added ✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl and removed 🐛 bug Something isn't working labels Mar 20, 2024
Copy link

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

Copy link

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@github-actions github-actions bot added the Stale label Sep 18, 2024
@Chriscbr Chriscbr removed the Stale label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request 📐 language-design Language architecture needs-discussion Further discussion is needed prior to impl 🧪 testing
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

4 participants