Skip to content

Commit

Permalink
PR #128: Enable clippy in CI
Browse files Browse the repository at this point in the history
Also fix some issues it reports.
  • Loading branch information
kaj authored Mar 4, 2022
2 parents c1fd46c + 88dfbe4 commit a060770
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ jobs:
with:
command: check

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features

test:
name: Test Suite
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project adheres to

## Unreleased

* Minor code cleanups.
* Enable clippy in CI and fix some things it complained about (PR #128).
* Update sass-spec test suite to 2022-02-24.


Expand Down
12 changes: 6 additions & 6 deletions src/spectest/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn handle_suite(
let mut tr = File::create(rssuitedir.join("testrunner.rs"))?;
tr.write_all(include_bytes!("testrunner.rs"))?;
}
handle_entries(&mut rs, &base, &suitedir, &rssuitedir, None, ignored)
handle_entries(&mut rs, base, &suitedir, &rssuitedir, None, ignored)
.map_err(|e| {
Error(format!("Failed to handle suite {:?}: {}", suite, e))
})
Expand Down Expand Up @@ -134,7 +134,7 @@ fn handle_entries(
if input.exists() {
spec_dir_to_test(
rs,
&suitedir,
suitedir,
&entry.file_name(),
precision,
)
Expand Down Expand Up @@ -184,7 +184,7 @@ fn handle_entries(
.collect();
handle_entries(
&mut rs,
&root,
root,
&entry.path(),
&rssuitedir,
precision,
Expand Down Expand Up @@ -304,7 +304,7 @@ fn handle_hrx_part(
if archive.get(&format!("{}input.scss", prefix)).is_some() {
let fixture = load_test_fixture_hrx(
name.map(str::to_owned),
&archive,
archive,
prefix,
options,
)?;
Expand Down Expand Up @@ -337,7 +337,7 @@ fn handle_hrx_part(
handle_hrx_part(
rs,
suite,
&archive,
archive,
&format!("{}{}", prefix, name),
options.precision,
runner.clone().with_cwd(name),
Expand Down Expand Up @@ -404,7 +404,7 @@ fn load_test_fixture_dir(
static EXPECTED_ERROR_FILENAMES: &[&str] = &["error-dart-sass", "error"];

let name = specdir.file_name().map(|s| s.to_string_lossy().to_string());
let mut options = load_options(&specdir)?;
let mut options = load_options(specdir)?;
options.precision = options.precision.or(precision);
let input = content(&specdir.join(INPUT_FILENAME))?;

Expand Down
2 changes: 1 addition & 1 deletion src/spectest/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct Options {

impl Options {
pub fn parse(options: &str) -> Result<Options, Error> {
match &YamlLoader::load_from_str(&options)?[..] {
match &YamlLoader::load_from_str(options)?[..] {
[] => Err(Error(format!("Found zero-doc options {:?}", options))),
[options] => {
//eprintln!("Found options: {:?}", options);
Expand Down
2 changes: 1 addition & 1 deletion src/spectest/testfixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,5 @@ fn normalize_output_css(css: &str) -> String {
lazy_static! {
static ref RE: Regex = Regex::new("(?:\r?\n)+").unwrap();
}
RE.replace_all(&css, "\n").to_string()
RE.replace_all(css, "\n").to_string()
}
2 changes: 1 addition & 1 deletion src/spectest/testrunner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl FileContext for TestFileContext {
&self,
name: &str,
) -> Result<Option<(Self, String, Self::File)>, Error> {
let mut cwd: &str = &self.cwd.trim_end_matches('/');
let mut cwd = self.cwd.trim_end_matches('/');
let mut lname = name;
while let Some(name) = lname.strip_prefix("../") {
cwd = cwd.rfind('/').map(|p| &self.cwd[..p]).unwrap_or("");
Expand Down

0 comments on commit a060770

Please sign in to comment.