-
Notifications
You must be signed in to change notification settings - Fork 1.9k
cargo QoL improvements #4228
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
Merged
Merged
cargo QoL improvements #4228
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5e0a820
Allow helper tools to be run via cargo run
roypat 0c0c014
test: Allow get_binary to compile example from different package
roypat 371de0e
Turn log-instrument binaries into examples
roypat 9169fc1
Merge branch 'main' into more-cargo-run
roypat bb76879
Merge branch 'main' into more-cargo-run
roypat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""Checks that the output of instrumentation examples is correct""" | ||
import pytest | ||
|
||
from framework import utils | ||
from host_tools.cargo_build import get_binary | ||
|
||
EXPECTED_OUTPUTS = { | ||
"one": """[2023-10-12T16:29:00Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:29:00Z DEBUG one] cmp: true | ||
[2023-10-12T16:29:00Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:29:00Z INFO one] 4 | ||
[2023-10-12T16:29:00Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:29:00Z DEBUG one] cmp: false | ||
[2023-10-12T16:29:00Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:29:00Z INFO one] 6 | ||
[2023-10-12T16:29:00Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:29:00Z DEBUG one] cmp: false | ||
[2023-10-12T16:29:00Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:29:00Z INFO one] 7""".splitlines(), | ||
"two": """[2023-10-12T16:29:30Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:29:30Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:29:30Z INFO two] None | ||
[2023-10-12T16:29:30Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:29:30Z DEBUG two] [\"a\", \"b\"] | ||
[2023-10-12T16:29:30Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:29:30Z INFO two] Some([\"a\", \"b\"])""".splitlines(), | ||
"three": """[2023-10-12T16:30:04Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:30:04Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:30:04Z INFO three] None | ||
[2023-10-12T16:30:04Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:30:04Z DEBUG three] [\"a\", \"b\"] | ||
[2023-10-12T16:30:04Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:30:04Z INFO three] Some([\"a\", \"b\"])""".splitlines(), | ||
"four": """[2023-10-12T16:30:37Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:30:37Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:30:37Z INFO four] None | ||
[2023-10-12T16:30:37Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:30:37Z DEBUG four] [\"a\", \"b\"] | ||
[2023-10-12T16:30:37Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:30:37Z INFO four] Some([\"a\", \"b\"])""".splitlines(), | ||
"five": """[2023-10-12T16:31:12Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:31:12Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:31:12Z INFO five] None | ||
[2023-10-12T16:31:12Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:31:12Z DEBUG five] [\"a\", \"b\"] | ||
[2023-10-12T16:31:12Z DEBUG five] 23 | ||
[2023-10-12T16:31:12Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:31:12Z INFO five] Some([\"a\", \"b\"])""".splitlines(), | ||
"six": """[2023-10-12T16:31:54Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:31:54Z DEBUG six] cmp: true | ||
[2023-10-12T16:31:54Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:31:54Z INFO six] 4 | ||
[2023-10-12T16:31:54Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:31:54Z DEBUG six] cmp: false | ||
[2023-10-12T16:31:54Z TRACE log_instrument] ThreadId(1)::one>>two | ||
[2023-10-12T16:31:54Z DEBUG six] res: 0 | ||
[2023-10-12T16:31:54Z TRACE log_instrument] ThreadId(1)::one<<two | ||
[2023-10-12T16:31:54Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:31:54Z INFO six] 0 | ||
[2023-10-12T16:31:54Z TRACE log_instrument] ThreadId(1)>>one | ||
[2023-10-12T16:31:54Z DEBUG six] cmp: false | ||
[2023-10-12T16:31:54Z TRACE log_instrument] ThreadId(1)::one>>two | ||
[2023-10-12T16:31:54Z DEBUG six] res: 1 | ||
[2023-10-12T16:31:54Z TRACE log_instrument] ThreadId(1)::one<<two | ||
[2023-10-12T16:31:54Z TRACE log_instrument] ThreadId(1)<<one | ||
[2023-10-12T16:31:54Z INFO six] 1""".splitlines(), | ||
} | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"example, expected_output", EXPECTED_OUTPUTS.items(), ids=EXPECTED_OUTPUTS | ||
) | ||
def test_instrumentation_example_output(example, expected_output): | ||
"""Test the output of instrumentation examples does not change""" | ||
example_binary = get_binary("log-instrument", example=example) | ||
|
||
# Logging output goes to stderr | ||
_, stdout, stderr = utils.run_cmd(str(example_binary)) | ||
|
||
assert not stdout | ||
|
||
lines = stderr.splitlines() | ||
assert len(lines) == len(expected_output) | ||
for line_number, line in enumerate(stderr.splitlines()): | ||
# Need to strip off timestamps | ||
assert line[20:] == expected_output[line_number][20:] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.