-
Notifications
You must be signed in to change notification settings - Fork 385
Make cargo-miri run documentation tests #1671
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
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f7bfbe7
Prototype: make cargo-miri run doc-tests
teryror 46e9dbc
Add check builds to support compile_fail doc-tests
teryror 11c3029
Play back stdin only when called from rustdoc
teryror 75053be
Update test-cargo-miri
teryror b10a1b0
Update README, add more comments, cleanup test-cargo-miri
teryror 10115cd
Update README.md
teryror 8b29e57
Enable doc-tests in cross-mode tests
teryror f41d72c
Rename helper function
teryror a815a42
Update assertion
teryror 154fb52
Resolve merge conflicts
teryror 10345ff
Detect cross-mode and skip doc-tests
teryror 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
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
and the working directory to contain the cargo-miri-test project. | ||
''' | ||
|
||
import sys, subprocess, os | ||
import sys, subprocess, os, re | ||
|
||
CGREEN = '\33[32m' | ||
CBOLD = '\33[1m' | ||
|
@@ -21,6 +21,10 @@ def cargo_miri(cmd): | |
args += ["--target", os.environ['MIRI_TEST_TARGET']] | ||
return args | ||
|
||
def normalize_stdout(str): | ||
str = str.replace("src\\", "src/") # normalize paths across platforms | ||
return re.sub("finished in \d+\.\d\ds", "finished in $TIME", str) | ||
|
||
def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}): | ||
print("Testing {}...".format(name)) | ||
## Call `cargo miri`, capture all output | ||
|
@@ -36,7 +40,7 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}): | |
(stdout, stderr) = p.communicate(input=stdin) | ||
stdout = stdout.decode("UTF-8") | ||
stderr = stderr.decode("UTF-8") | ||
if p.returncode == 0 and stdout == open(stdout_ref).read() and stderr == open(stderr_ref).read(): | ||
if p.returncode == 0 and normalize_stdout(stdout) == open(stdout_ref).read() and stderr == open(stderr_ref).read(): | ||
# All good! | ||
return | ||
# Show output | ||
|
@@ -71,26 +75,27 @@ def test_cargo_miri_run(): | |
def test_cargo_miri_test(): | ||
# rustdoc is not run on foreign targets | ||
is_foreign = 'MIRI_TEST_TARGET' in os.environ | ||
rustdoc_ref = "test.stderr-empty.ref" if is_foreign else "test.stderr-rustdoc.ref" | ||
default_ref = "test.cross-target.stdout.ref" if is_foreign else "test.default.stdout.ref" | ||
filter_ref = "test.filter.cross-target.stdout.ref" if is_foreign else "test.filter.stdout.ref" | ||
|
||
test("`cargo miri test`", | ||
cargo_miri("test"), | ||
"test.default.stdout.ref", rustdoc_ref, | ||
default_ref, "test.stderr-empty.ref", | ||
env={'MIRIFLAGS': "-Zmiri-seed=feed"}, | ||
) | ||
test("`cargo miri test` (no isolation)", | ||
cargo_miri("test"), | ||
"test.default.stdout.ref", rustdoc_ref, | ||
default_ref, "test.stderr-empty.ref", | ||
env={'MIRIFLAGS': "-Zmiri-disable-isolation"}, | ||
) | ||
test("`cargo miri test` (raw-ptr tracking)", | ||
cargo_miri("test"), | ||
"test.default.stdout.ref", rustdoc_ref, | ||
default_ref, "test.stderr-empty.ref", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you change one of these tests to also pass |
||
env={'MIRIFLAGS': "-Zmiri-track-raw-pointers"}, | ||
) | ||
test("`cargo miri test` (with filter)", | ||
cargo_miri("test") + ["--", "--format=pretty", "le1"], | ||
"test.filter.stdout.ref", rustdoc_ref, | ||
filter_ref, "test.stderr-empty.ref", | ||
) | ||
test("`cargo miri test` (test target)", | ||
cargo_miri("test") + ["--test", "test", "--", "--format=pretty"], | ||
|
Oops, something went wrong.
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.