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

Add exclude-environment config field and more stringent tests #18

Closed
wants to merge 5 commits into from

Conversation

PaulKMueller
Copy link
Collaborator

Motivation

Using conda-deny for all but some environments in pixi projects is an often occurring use case.
Instead of having to recount all environment names apart from e.g. "lint", the exclude-environment field allows you to specify environments to ignore.

Changes

Configurations like the following:

[tool.conda-deny]
license-whitelist = "license_whitelist.toml"
environment=["default", "first_env", "second_env", "third_env", "fourth_env", "fifth_env", "sixth_env", "seventh_env"]

can now be simplified to:

[tool.conda-deny]
license-whitelist = "license_whitelist.toml"
exclude-environment=["lint"]

Also: The integration tests prior to this PR were quite forgiving. They are now a lot more stringent.

@PaulKMueller PaulKMueller self-assigned this Nov 24, 2024
@PaulKMueller PaulKMueller added the enhancement New feature or request label Nov 24, 2024
Comment on lines +24 to +29
let line_count = stdout.lines().count();
let expected_line_count = 297;
assert_eq!(
line_count, expected_line_count,
"Unexpected number of output lines"
);
Copy link
Member

Choose a reason for hiding this comment

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

this might be annoying to adjust every time the output format changes
i usually just assert that a specific string is contained in stdout (same for the other test cases)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did that previously.
Unfortunately since the tests are executed in CI (and local stdout differs from Github stdout) this broke things quite frequently for me.

let exit_status = output.status.code().unwrap();
assert_eq!(exit_status, 1, "Unexpected exit status");

let stdout = str::from_utf8(&output.stdout).expect("Failed to convert output to string");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let stdout = str::from_utf8(&output.stdout).expect("Failed to convert output to string");
let stdout = str::from_utf8(&output.stdout).unwrap();

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What is the benefit of this?

Copy link
Member

@pavelzw pavelzw Dec 3, 2024

Choose a reason for hiding this comment

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

less letters that basically do the same thing
i use unwrap always during testing as this is the fastest way to get to results

assert_eq!(
line_count, expected_line_count,
"Unexpected number of output lines"
);
}

#[test]
fn test_default_use_case_pyproject_list() {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@pavelzw pavelzw Dec 2, 2024

Choose a reason for hiding this comment

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

could we make the lockfile smaller (for example by only adding conda-deny to pixi.toml)?
adding 7k lines for a single test case is a bit much IMO 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants