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

Test themes #47761

Merged
merged 9 commits into from Feb 9, 2018
Merged

Test themes #47761

merged 9 commits into from Feb 9, 2018

Conversation

GuillaumeGomez
Copy link
Member

@QuietMisdreavus
Copy link
Member

[00:05:16] tidy error: /checkout/src/tools/rustdoc-themes/test-themes.py: incorrect license
[00:05:17] some tidy checks failed

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 26, 2018
@GuillaumeGomez GuillaumeGomez force-pushed the test-themes branch 3 times, most recently from ab0eb13 to 6b716a6 Compare January 26, 2018 19:20
@bors
Copy link
Contributor

bors commented Jan 26, 2018

☔ The latest upstream changes (presumably #47748) made this pull request unmergeable. Please resolve the merge conflicts.

cmd.args(&["src/tools/rustdoc-themes/test-themes.py", rustdoc.to_str().unwrap()]);
cmd.env("RUSTC_STAGE", self.compiler.stage.to_string())
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
.env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, builder.build.build))
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be self.compiler.host as the second argument.

}

fn run(self, builder: &Builder) {
let rustdoc = builder.out.join("bootstrap/debug/rustdoc");
Copy link
Member

Choose a reason for hiding this comment

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

This should be a call to builder.rustdoc. Otherwise it may not have been built yet.


fn run(self, builder: &Builder) {
let rustdoc = builder.out.join("bootstrap/debug/rustdoc");
let mut cmd = Command::new(builder.config.python.clone().unwrap());
Copy link
Member

Choose a reason for hiding this comment

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

Please call expect("python not defined") or something similar.

pathes.iter().cloned().collect()
}

pub fn load_css_pathes(v: &[u8]) -> CssPath {
Copy link
Member

Choose a reason for hiding this comment

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

nit: paths

print_err('No theme found in "{}"...'.format(THEME_DIR_PATH))
return 1
args = [rustdoc_bin, '-Z', 'unstable-options', '--theme-checker']
args.extend(themes)
Copy link
Member

Choose a reason for hiding this comment

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

So it's not super clear to me why we need this script instead of inlining this logic into rustbuild. That would be my preference...

Copy link
Member Author

Choose a reason for hiding this comment

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

It's simpler and more flexible from my point of view.

Copy link
Member

Choose a reason for hiding this comment

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

How is it better to have this in a python file vs having it in rustbuild? I prefer that we have as much as possible in rustbuild and in Rust. This is out-of-band and nearly impossible to find unless you know about it.

Copy link
Member

Choose a reason for hiding this comment

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

I'm going to side with @Mark-Simulacrum here. The fact that this script is in Python doesn't add anything over just having the logic inline with its call in rustbuild. It's literally just "for all the .css files in this folder except main.css, call rustdoc with these extra flags and that file". Python just seems to be invoked here for the directory-crawling aspect? You can get close enough with std::fs::read_dir, IMO.

@GuillaumeGomez GuillaumeGomez force-pushed the test-themes branch 2 times, most recently from 819679f to 5083535 Compare January 27, 2018 16:46
@GuillaumeGomez
Copy link
Member Author

@Mark-Simulacrum: Updated as you suggested.

@mark-i-m
Copy link
Member

Cc rust-lang/rfcs#1987

Copy link
Member

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

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

I'm a little worried that this effectively contains a homebrew CSS parser. Would including a separate crate for that be too much of a problem?

print!(" - Checking \"{}\"...", theme_file);
let (success, differences) = theme::test_theme_against(theme_file, &paths);
if !differences.is_empty() || !success {
eprintln!(" FAILED");
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little alarmed that the "Checking {}" and "FAILED" are sent to different output streams. Is this standard practice elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure. I'll give it a look.

d {}
"#;
let paths = load_css_paths(text.as_bytes());
assert!(paths.children.get(&CssPath::new("a b c d".to_owned())).is_some());
Copy link
Member

Choose a reason for hiding this comment

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

.get(..).is_some() is the same as .contains(..)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh indeed, thanks!

@GuillaumeGomez
Copy link
Member Author

I'm a little worried that this effectively contains a homebrew CSS parser. Would including a separate crate for that be too much of a problem?

Not sure it's worth it. I mean, it's quite small and strongly integrated into rustdoc. This "CSS parser" is very basic and only get css-selectors by parsing comments and blocks.

@GuillaumeGomez
Copy link
Member Author

So what should we do about this PR? We need it quickly if we want to add other themes (and to check those provided by users when they build docs with their own theme).

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

I would like the python script removed, and then I think I'm mostly okay with landing this.

pub children: HashSet<CssPath>,
}

// This PartialEq implementation IS NOT COMMUTATIVE!!!
Copy link
Member

Choose a reason for hiding this comment

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

This seems bad. Perhaps we shouldn't have a PartialEq (and much less Eq) impl and instead just have a method that does this? I'm somewhat concerned that we're going to run into problems with stdlib's HashSet etc where things oddly fail to work.

Copy link
Member Author

Choose a reason for hiding this comment

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

I appreciated to be able to use ==. 😞 I can do it in a method, but the basic issue will be the same: the check won't be commutative. We want to check that the second object implements all the first one's rules. If it has more, we don't care. We don't require an absolute equality. That's why I did it like this.

Copy link
Member

Choose a reason for hiding this comment

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

Hm. Yeah, I'd probably prefer a method (with a name like contains_rules or something), but I guess I don't care too much. Not a blocking concern, probably.

}
}

impl Hash for CssPath {
Copy link
Member

Choose a reason for hiding this comment

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

This feels derivable?

Copy link
Member Author

Choose a reason for hiding this comment

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

No because to have Hash implemented for CssPath, you need to have it implemented on CssPath. :p

Copy link
Member

Choose a reason for hiding this comment

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

Ah. Okay.

@GuillaumeGomez
Copy link
Member Author

@Mark-Simulacrum: I'd prefer to keep the python script if possible for potential evolutions. For now it's quite simple but I have a few others things that'll be required later on with some new features. Having to update the builder rust code instead of having a small outside python script doesn't seem to be a very good idea from my point of view.

@Mark-Simulacrum
Copy link
Member

I guess I'm failing to see why editing the Rust code is easier/better than the Python code. But I feel like we're somewhat talking past each other -- I don't think we've brought up any new arguments in this discussion for a while. Could we perhaps move the python code into Rust, and if later down the line we add additional features to it that make it easier to implement in Python, we can move it over again? I guess my main point here is that while Python may be easier for some (including perhaps you!) to edit and understand, I find Rust much easier to understand (and expect that to be true for the majority of Rust contributors). Does that help explain my reasoning for why it seems better to keep as much code as possible in Rust?

@mark-i-m
Copy link
Member

mark-i-m commented Feb 4, 2018

In my limited experience, projects with multiple languages tend to be more work to maintain in the long run... IMHO, it would be good to keep everything in Rust...

@GuillaumeGomez
Copy link
Member Author

Hum ok... So should I just replace the python code in rust or should I move this code directly into the builder?

@QuietMisdreavus
Copy link
Member

Since you told me you want to extend this script in the future, i think it will be fine to just replace it with rust, without integrating it into rustbuild.

@Mark-Simulacrum
Copy link
Member

Integrating it as a function in rustbuild would be easier as you don't have to worry about compiling it.

@GuillaumeGomez
Copy link
Member Author

@Mark-Simulacrum: My only concern with this is that you don't know this test exists unless you wrote it. I like having the match between the test runner and a folder.

@GuillaumeGomez
Copy link
Member Author

I converted the python script into rust.

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

I'm mostly happy with this. r=me if you remove host in failure of just using compiler.host, otherwise I'd like to review again. Thanks for bearing with me!

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RustdocTheme {
pub compiler: Compiler,
pub host: Interned<String>,
Copy link
Member

Choose a reason for hiding this comment

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

Why is this not compiler.host? It should be afaict... or it should be named differently, or have some documentation. Right now this seems likely to be brittle in some configurations.

pub children: HashSet<CssPath>,
}

// This PartialEq implementation IS NOT COMMUTATIVE!!!
Copy link
Member

Choose a reason for hiding this comment

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

Hm. Yeah, I'd probably prefer a method (with a name like contains_rules or something), but I guess I don't care too much. Not a blocking concern, probably.

}
}

impl Hash for CssPath {
Copy link
Member

Choose a reason for hiding this comment

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

Ah. Okay.

@GuillaumeGomez
Copy link
Member Author

Updated.

@GuillaumeGomez
Copy link
Member Author

@bors r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Feb 8, 2018

📌 Commit dec9fab has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 8, 2018
@bors
Copy link
Contributor

bors commented Feb 8, 2018

⌛ Testing commit dec9fab with merge ec9bf02...

@bors
Copy link
Contributor

bors commented Feb 8, 2018

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 8, 2018
@kennytm
Copy link
Member

kennytm commented Feb 8, 2018

@bors retry

3 hour timeout in check-aux x86_64-pc-windows-msvc and dist i686-pc-windows-gnu (stuck when cloning rust-by-example).

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 8, 2018
@bors
Copy link
Contributor

bors commented Feb 8, 2018

⌛ Testing commit dec9fab with merge 4723336...

@bors
Copy link
Contributor

bors commented Feb 8, 2018

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 8, 2018
@kennytm
Copy link
Member

kennytm commented Feb 8, 2018

@bors retry (3 hour timeout, check x86_64-pc-windows-msvc)

This PR keeps timing out in some unconventional places.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 8, 2018
@GuillaumeGomez
Copy link
Member Author

All rust test chain is weird.

@bors
Copy link
Contributor

bors commented Feb 9, 2018

⌛ Testing commit dec9fab with merge 02537fb...

@bors
Copy link
Contributor

bors commented Feb 9, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: Mark-Simulacrum
Pushing 02537fb to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants