Skip to content

More resilient stdout parsing of dialer stdout#224

Merged
MarcoPolo merged 3 commits intomasterfrom
marco/json-unexpected-end
Jul 13, 2023
Merged

More resilient stdout parsing of dialer stdout#224
MarcoPolo merged 3 commits intomasterfrom
marco/json-unexpected-end

Conversation

@MarcoPolo
Copy link
Contributor

@MarcoPolo MarcoPolo commented Jul 5, 2023

First off, I don't really understand why compose split the line here. It may be a bug in zig-libp2p, but there are no other callers of stdout (no race). And there's nothing fancy going on, it just writes to the stdout file the bytes directly (no buffering).

Whatever the reason, we should probably be a bit more resilient with parsing of the output compared to the initial regex. This adds a helper to help with parsing compose's output as well as a test case to make sure that we don't silently break this.

To avoid adding a whole new dependency on some test framework that opens the door to the nightmare of JS bundling, the test is a simple function that is run if you run the file directly (as opposed to importing it). And it's run as part of npm test when you run the interop tests (so it'll happen in CI as well).

@MarcoPolo MarcoPolo force-pushed the marco/json-unexpected-end branch from 7f1842d to e7865dc Compare July 6, 2023 01:32
@thomaseizinger
Copy link
Contributor

To avoid adding a whole new dependency on some test framework that opens the door to the nightmare of JS bundling

I still think deno could be a good fit for the problem we have here but I agree with your particular solution :)

@MarcoPolo
Copy link
Contributor Author

Could I get a review from someone? friendly ping to @thomaseizinger or @mxinden

@MarcoPolo
Copy link
Contributor Author

Merging this for now since it's been causing a lot of false negatives. I'm still interested in a review please :)

@MarcoPolo MarcoPolo merged commit fff587f into master Jul 13, 2023
@MarcoPolo MarcoPolo deleted the marco/json-unexpected-end branch July 13, 2023 19:14
Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

Sorry for the late review, one suggestion but thank you for the fix!

"main": "testplans.ts",
"scripts": {
"test": "ts-node testplans.ts",
"test": "ts-node src/compose-stdout-helper.ts && ts-node testplans.ts",
Copy link
Contributor

Choose a reason for hiding this comment

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

Does shell glob expansion work in here? We could move these files to a tests dir and just run all of them.

Copy link
Contributor

Choose a reason for hiding this comment

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

For that, I'd then probably be cleaner to keep the helper in src and just make another small file that runs the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. Will do this change once we have more than one test file :)

codemaestro64 pushed a commit to codemaestro64/test-plans that referenced this pull request Oct 28, 2025
* More resilient stdout parsing of dialer stdout

* Add another test case

* Handle JS cases where timings aren't the only thing on stdout
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.

3 participants