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

fix(tests): add missing import for tests #1375

Merged
merged 1 commit into from
Nov 22, 2022
Merged

fix(tests): add missing import for tests #1375

merged 1 commit into from
Nov 22, 2022

Conversation

alrevuelta
Copy link
Contributor

Due to a missing import, some tests could not be run isolated. The issue can be reproduced as follows, and it applies to all modified tests where the chronicles import was added.

$ ./env.sh bash
$ nim c -r ./tests/v2/test_waku_filter.nim

/Users/xxx/Github/nwaku/tests/v2/test_waku_filter.nim(18, 95) template/generic instantiation of `async` from here
/Users/xxx/Github/nwaku/tests/v2/test_waku_filter.nim(20, 30) template/generic instantiation of `new` from here
/Users/xxx/Github/nwaku/waku/v2/node/peer_manager/peer_manager.nim(149, 11) template/generic instantiation of `debug` from here
/Users/xxx/Github/nwaku/vendor/nim-chronicles/chronicles.nim(359, 10) template/generic instantiation of `log` from here
/Users/xxx/Github/nwaku/vendor/nim-chronicles/chronicles.nim(332, 21) Error: undeclared identifier: 'activeChroniclesStream'
candidates (edit distance, scope distance); see '--spellSuggest':
 (13, 7): 'IfDvbrccUpstream' [enumField declared in /Users/xxx/Github/nwaku/vendor/nim-chronos/chronos/transports/osnet.nim(176, 5)]
 (13, 7): 'asyncstream' [module declared in /Users/xxx/Github/nwaku/vendor/nim-chronos/chronos/streams/chunkstream.nim(12, 8)]
 (13, 7): 'asyncstream' [module declared in /Users/xxx/Github/nwaku/vendor/nim-chronos/chronos/transport.nim(10, 17)]
 (13, 7): 'chunkstream' [module declared in /Users/xxx/Github/nwaku/vendor/nim-chronos/chronos/transport.nim(10, 17)]
 (13, 7): 'initStream' [method declared in /Users/xxx/Github/nwaku/vendor/nim-libp2p/libp2p/protocols/secure/secure.nim(63, 8)]
 (13, 7): 'initStream' [method declared in /Users/xxx/Github/nwaku/vendor/nim-libp2p/libp2p/protocols/secure/secure.nim(63, 8)]
 (13, 7): 'initStream' [method declared in /Users/xxx/Github/nwaku/vendor/nim-libp2p/libp2p/stream/connection.nim(75, 8)]
 (13, 7): 'initStream' [method declared in /Users/xxx/Github/nwaku/vendor/nim-libp2p/libp2p/stream/connection.nim(75, 8)]
 (13, 7): 'initStream' [method declared in /Users/xxx/Github/nwaku/vendor/nim-libp2p/libp2p/stream/lpstream.nim(154, 8)]
 (13, 7): 'initStream' [method declared in /Users/xxx/Github/nwaku/vendor/nim-libp2p/libp2p/stream/lpstream.nim(154, 8)]

@alrevuelta alrevuelta marked this pull request as ready for review November 14, 2022 10:19
Copy link
Contributor

@rymnc rymnc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

```bash
# Get a shell with the right environment variables set
./env.sh bash
# Run a specific test
nim c -r ./tests/v2/test_waku_filter.nim
```

And and alter compile options as you want. For example, if you want a less verbose output you can do the following. For more, refer to the [compiler flags](https://nim-lang.org/docs/nimc.html#compiler-usage) and [chronicles documentation](https://github.com/status-im/nim-chronicles#compile-time-configuration).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
And and alter compile options as you want. For example, if you want a less verbose output you can do the following. For more, refer to the [compiler flags](https://nim-lang.org/docs/nimc.html#compiler-usage) and [chronicles documentation](https://github.com/status-im/nim-chronicles#compile-time-configuration).
and alter compile options as you want. For example, if you want a less verbose output you can do the following. For more, refer to the [compiler flags](https://nim-lang.org/docs/nimc.html#compiler-usage) and [chronicles documentation](https://github.com/status-im/nim-chronicles#compile-time-configuration).

@status-im-auto
Copy link
Collaborator

status-im-auto commented Nov 14, 2022

Jenkins Builds

Click to see older builds (8)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 865e7b3 #1 2022-11-14 10:34:40 ~15 min macos 📦bin
865e7b3 #1 2022-11-14 10:35:02 ~15 min linux 📄log
✔️ 10dd360 #2 2022-11-14 14:13:31 ~15 min linux 📦bin
✔️ 10dd360 #2 2022-11-14 14:22:25 ~24 min macos 📦bin
✔️ 873e587 #3 2022-11-17 15:50:31 ~15 min linux 📦bin
✔️ 873e587 #3 2022-11-17 15:55:31 ~20 min macos 📦bin
e4de90c #4 2022-11-18 10:52:10 ~15 min linux 📄log
✔️ e4de90c #4 2022-11-18 10:54:06 ~17 min macos 📦bin
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 1465de7 #5 2022-11-21 11:27:17 ~15 min linux 📦bin
✔️ 1465de7 #5 2022-11-21 11:31:48 ~19 min macos 📦bin
✔️ d8ccfc7 #6 2022-11-21 14:36:21 ~14 min linux 📦bin
✔️ d8ccfc7 #6 2022-11-21 14:43:40 ~22 min macos 📦bin

Copy link
Contributor

@LNSD LNSD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM ✅

One question: are this changes adding an UnusedImport warning to the test2 compilation logs? If so, then I would rather investigate a better approach that do not introduce those warnings and allows compiling the module individually.

Some context:

The amount of warnings we have is so high that is already causing "alert fatigue", and we can miss relevant issues for the PR. We need to address them as a maintenance chore.

@LNSD
Copy link
Contributor

LNSD commented Nov 14, 2022

are these changes adding an UnusedImport warning to the test2 compilation logs?

I answer my question: Yes, they do.

https://github.com/status-im/nwaku/actions/runs/3460521398/jobs/5777145106#step:7:44

Then, I would investigate a better approach that does not introduce those warnings and allows compiling the module individually.

Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for fixing this, as these individual tests have been broken for a while.

I agree with @LNSD about perhaps finding a way of doing this that does not increase compiler warnings (we've been struggling to stay ahead here due to Nim limitations). Is it possible to use the {.used.} pragma (explained here) on the specific offending imports?
If there's no easy and clean way of avoiding the warnings, I think we should track it in a separate issue and come up with a strategy, but that would be subsequent to fixing the tests.

@alrevuelta
Copy link
Contributor Author

@LNSD good catch. A simple approach could be to use this but I wouldn't like to have the test code full of these off/on statements. Another approach is to find the root cause of the issue and fix it properly, but have the feeling this will take some time. As I see it this has a really low prio, so I would manually disable the warnings as @jm-clius kind of suggested.

@LNSD
Copy link
Contributor

LNSD commented Nov 14, 2022

so I would manually disable the warnings as @jm-clius kind of suggested.

What do you mean by "manually disable" the warnings? 👀

@alrevuelta
Copy link
Contributor Author

What do you mean by "manually disable" the warnings? 👀

Disregard my comment. I was expecting this to work, but it does not.

{. warning[UnusedImport]:off .}

import "sequtils"

{. warning[UnusedImport]:on .}

import "tables"

echo "hi there"

But:

Warning: imported and not used: 'sequtils' [UnusedImport]
Warning: imported and not used: 'tables' [UnusedImport]

I was ofc expecting to warn only about tables.

@LNSD
Copy link
Contributor

LNSD commented Nov 16, 2022

What are the plans for this PR? Shall we close it and open an issue to investigate a solution?

cc @jm-clius @alrevuelta

@alrevuelta
Copy link
Contributor Author

alrevuelta commented Nov 16, 2022

@LNSD will give it a shot before the end of the week. if it turns out to be too much, i would merge the PR and open an issue to track it. I think its better a "unused import" than a compile error. wdyt?

@jm-clius
Copy link
Contributor

Let's merge this. The issue here is incorrect compiler message of unused import for an import that's clearly used. First step is to fix the tests, which indeed affects development (I ran into this as well). Next step is to see if there is a solution around this limitation of the Nim compiler.

@alrevuelta
Copy link
Contributor Author

@jm-clius great! tracking it here: #1398

@alrevuelta alrevuelta force-pushed the fix-tests branch 2 times, most recently from e4de90c to 1465de7 Compare November 21, 2022 11:11
@alrevuelta alrevuelta merged commit 1e8e60c into master Nov 22, 2022
@alrevuelta alrevuelta deleted the fix-tests branch November 22, 2022 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants