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

Some corrections that remove platform specific code, causing tests to fail on Windows. #889

Closed
wants to merge 0 commits into from

Conversation

alvonellos
Copy link

And I noticed some javadoc tags were messed up too, so I cleaned those up as well.

@alvonellos
Copy link
Author

alvonellos commented Jan 27, 2024

I tested this thoroughly on local and on wsl linux. Are there any spots I can jump in and take a load off?

@alvonellos alvonellos closed this Jan 27, 2024
@alvonellos alvonellos reopened this Jan 27, 2024
@ArneBab
Copy link
Contributor

ArneBab commented Jan 27, 2024

The code changes look good! Thank you very much for contributing!

The only change that would be important before merging is to keep the indentation consistent with the surrounding code (to avoid merge conflicts with other pull-requests we avoid re-indenting everything, so we’re stuck on the current indentation scheme). You might not see the differences in indentation from IntelliJ, they often only show up in the diff-view on github — or on other systems which use a different tab-width.

For stepping in: depending on what you like to do it can be best to start with small things that annoy you (like this pull-request), or to take a task that is likely to have a big impact, i.e. from https://github.com/hyphanet/wiki/wiki/High-Impact-tasks

If you want to see your changes in action quickly, the easiest is to start by improving plugins, because those can be released independently from the full node. Also they would benefit a lot from improvements. See for example some tasks in the section on advanced features: https://github.com/hyphanet/wiki/wiki/High-Impact-tasks#goal-make-advanced-features-easy-to-use

@alvonellos
Copy link
Author

@ArneBab I made some changes. I think I fixed the spacing? Is there a preferences file that enforces uniform code format?

@alvonellos
Copy link
Author

The code changes look good! Thank you very much for contributing!

The only change that would be important before merging is to keep the indentation consistent with the surrounding code (to avoid merge conflicts with other pull-requests we avoid re-indenting everything, so we’re stuck on the current indentation scheme). You might not see the differences in indentation from IntelliJ, they often only show up in the diff-view on github — or on other systems which use a different tab-width.

For stepping in: depending on what you like to do it can be best to start with small things that annoy you (like this pull-request), or to take a task that is likely to have a big impact, i.e. from https://github.com/hyphanet/wiki/wiki/High-Impact-tasks

If you want to see your changes in action quickly, the easiest is to start by improving plugins, because those can be released independently from the full node. Also they would benefit a lot from improvements. See for example some tasks in the section on advanced features: https://github.com/hyphanet/wiki/wiki/High-Impact-tasks#goal-make-advanced-features-easy-to-use

I'll take a look at some of the other tasks that are available. :) Thanks for the quick reply @ArneBab

@@ -87,15 +87,19 @@ public void readFilter(
readcount = dis.read(nextbyte);
continue;
}
if (isCarriageReturn(nextbyte)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like it changes the behaviour of the filter but I can’t see that the test is being changed in reaction to this, so either there is no test (in which case, please add a test) or the test doesn’t actually test this behvaiour (in which case, please add a test for the behvaviour).

@@ -164,7 +168,7 @@ public void readFilter(
}
// write the newline if we're not at EOF
if (readcount != -1){
dos.write(nextbyte);
dos.write(System.lineSeparator().getBytes(StandardCharsets.UTF_8));
Copy link
Contributor

Choose a reason for hiding this comment

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

This change makes the filter’s behaviour dependent on the OS Fred is being run on. Is that actually what we want? In my opinion our filters should behave the same everywhere, especially as the output of the filter is supposed to be usable on every OS. Now, we of course do not know here what OS the output of the filter is being used on so really any choice we make here is an arbitrary one, which is a rather long-winded way of saying that we shouldn’t actually change anything here. 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the likelyhood that we’ll use the file on Windows if the filter runs on Windows is pretty high. And there are still editors on Windows that display a file with \n as line separator as just one long line.

I don’t think any audio player makes that difference, though, so this is rather about people reading the code, not about functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

True, people using notepad.exe would probably prefer Windows-style line endings… 😁

But, this would also expose that the node is running on a Windows system. I’m not sure how much of an issue that is, though… are we worrying about that?

@@ -418,7 +418,7 @@ public StringBuilder generate(StringBuilder tagBuffer, int indentDepth ) {
}
} else {
if (newlineOpen(name)) {
tagBuffer.append('\n');
tagBuffer.append(System.lineSeparator());
Copy link
Contributor

Choose a reason for hiding this comment

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

Here it’s basically the same reasoning: we can’t actually know that the HTML file is being parsed on the same OS that we use to create the HTML.

@@ -15,7 +15,7 @@ public class PebbleUtilsTest {
@Test
public void addChildAddsCorrectlyEvaluatedSimpleTemplateToHtmlNode() throws IOException {
PebbleUtils.addChild(emptyParentNode, "pebble-utils-test-simple", model, null);
assertThat(emptyParentNode.generate(), equalTo("Test!\n"));
assertThat(emptyParentNode.generate(), equalTo("Test!" + System.lineSeparator()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Now, this is actually interesting. What we do want here is to test that the template substitution works correctly, which means that we very much do want to avoid using system-dependent behaviour here; however, that also means that we need to make sure that the source of the template contains exactly the line endings that we expect in the test. I guess the real fix here is to make sure that Git doesn’t change the line endings of the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I hadn’t thought of git changing the line endings in the test files! 🤦

That won’t happen in an unpacked tarball, so we’d get test failures there.

@alvonellos can you check whether the linesep can also be fixed by adding a .gitattributes file for our expected test output similar to this? https://shzhangji.com/blog/2022/08/31/configure-git-line-endings-across-oses/

Copy link
Author

Choose a reason for hiding this comment

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

I'm looking into this.

@alvonellos
Copy link
Author

alvonellos commented Jan 31, 2024 via email

@alvonellos
Copy link
Author

I will undo my changes here for the time being.

@alvonellos
Copy link
Author

I have made a new branch and pushed the git attributes change. There's still something funky going on with the M3U Filters. I'm looking into this.

@ArneBab
Copy link
Contributor

ArneBab commented Feb 1, 2024

Thank you! I know that it often feels strange to throw away code, but at least for me, finding the cleaner fix more than makes up for it. ❤️

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

Successfully merging this pull request may close these issues.

3 participants