-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Tests fail on windows because of newline #39
Comments
Good catch! File handles are lazy and don't load or parse their content unless absolutely necessary so right now when comparing files for equality I'm using their serialized representation. One change I actually made a few days ago was implementing comparisons using the deserialized value for json files as I was running into a different field ordering in CI. But it's still not ideal so I just made the This should take care of the inconsistency with line endings on windows. Other than that there's not really any os-specific behavior, so I'm probably not going to start running tests on windows. I really like to keep my CI as fast as possible so unless I actually have platform-specific code in a project I try to keep it linux-only. Tell me if you encounter any other issue with this. |
In that case I'm going to play the part of the botnet matrix. Call me Neo :D |
The saga continues. Excerpt:
Also a quirk I noticed with OSX in my own repos: Apple seems to have a different file ordering, had an issue where I assumed the same order of reading files on every OS. |
Issue seems to be the I quickly tested with a hacky fix that just converts all path strings to posix path strings: def fix_paths(cfg: ProjectConfig):
if cfg.directory:
cfg.directory = Path(cfg.directory).as_posix()
if cfg.output:
cfg.output = Path(cfg.output).as_posix()
cfg.data_pack.load = [Path(p).as_posix() for p in cfg.data_pack.load]
cfg.resource_pack.load = [Path(p).as_posix() for p in cfg.resource_pack.load]
if cfg.templates:
cfg.templates = [Path(p).as_posix() for p in cfg.templates]
for entry in cfg.pipeline:
if isinstance(entry, ProjectConfig):
fix_paths(entry)
return cfg
@pytest.mark.parametrize("directory", os.listdir("tests/config_examples")) # type: ignore
def test_config_resolution(snapshot: Any, directory: str):
project_config = load_config(f"tests/config_examples/{directory}/beet.json")
fix_paths(project_config)
assert snapshot("json") == project_config.dict() That seems to fix all the problems with Paths.
Now Windows personally complains (thats why the error is in German, sry). Seems the cache checks |
Whoa thanks! Sorry I was busy. I didn't anticipate this but you're right, resolving the config file produces different paths on windows. I'm fine with the I also changed the cache matching test to use |
Great stuff, tests work like a charm now. Thanks for all the effort :D |
Setup:
Excerpt:
Tests seem to fail because of the differences of newlines: Windows
\r\n
vs Linux\n
.Since the project uses snapshot testing, I don't know how easily that can be fixed. In the case that it can, I recommend adding a matrix to the Github Action (an example from my repo)
The text was updated successfully, but these errors were encountered: