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

Styx tests should pass in windows #101

Merged
merged 10 commits into from
Mar 15, 2018

Conversation

dvlato
Copy link
Contributor

@dvlato dvlato commented Mar 2, 2018

Fixed several issues when trying to run the build in Windows.

Copy link
Contributor

@kvosper kvosper left a comment

Choose a reason for hiding this comment

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

I have left some comments.
I think we need to discuss how best to make Styx code multi-platform together before we try to make the changes.

On an unrelated, but important note, this branch fails to build on my machine, with checkstyle violations. We should also determine how best to run a windows-equivalent of make e2e (which is how we build locally on Mac).

* Copyright (C) 2013-2017 Expedia Inc.
*
* Copyright (C) 2013-2018 Expedia Inc.
* <p>
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to remove any formatting "help" that our IDEs add to the copyright notice, because it will cause the build process to add another copyright notice on top of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have addressed these issues with the IDE in another comment. Other than that, do you have any document with coding guidelines you follow? For instance, for the "use string literals" in tests part.

newPath = path.getParent();
private String removeAsterisk(String path) {
String newPath = path;
if (path.endsWith("*")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is not the same. The old code checks that the final part of the path is *, e.g. foo/bar/*, which is more strict than simply checking if the final character is *.
Do you believe the old logic is incorrect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So can the path have "*" anywhere other than after a slash? There are no tests for that condition in PathTrieTest. In Windows * is not a valid character for filenames, so I understood it was safe to remove it in any case. If it is not, I think we might want to make code more explicit regarding what Paths are valid.


@Test
public void listsResourcesFromFileSystemDirectory() {
Iterable<Resource> jars = resourceIndex.list(PLUGINS_FIXTURE_PATH.toString(), ".jar");

assertThat(jars, contains(resourceWithPath("oneplugin/url-rewrite-1.0-SNAPSHOT.jar")));
assertThat(jars, contains(resourceWithPath(EXISTING_PLUGIN_RELPATH)));
Copy link
Contributor

Choose a reason for hiding this comment

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

We follow a principle of leaving literal strings in tests where possible so that readers do not need to jump around the file to understand the test.

@@ -26,7 +26,7 @@
public void canAcquireClasspathResources() {
Resource resource = ResourceFactory.newResource("classpath:com/hotels/styx/api/io/resource.txt");

assertThat(resource, contains("This is an example resource.\nIt has content to use in automated tests."));
assertThat(resource, contains("This is an example resource."+System.lineSeparator()+"It has content to use in automated tests."));
Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to consider using String.format (with static imports) for these line separator cases.

e.g. assertThat(resource, contains(format("This is an example resource.%nIt has content to use in automated tests.")));

import static com.hotels.styx.StartupConfig.LOGBACK_CONFIG_LOCATION_VAR_NAME;
import static com.hotels.styx.StartupConfig.STYX_HOME_VAR_NAME;
import static com.hotels.styx.StartupConfig.newStartupConfigBuilder;
import static com.hotels.styx.StartupConfig.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use the * import in Styx as we like to only import exactly what we are using.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, that's due to IntelliJ settings. The IDE itself was changing the imports as per the "count to use (static) import with *" If you could do an export of the Settings -> Editor -> Code Style to verify that I don't have any other settings configured that break codestyle's expectations, that would be great.

@@ -107,7 +107,8 @@ public void createsMetricsJsonCorrectly() throws JsonProcessingException {
"\n" +
" },\n" +
" \"version\":\"3.1.3\"\n" +
"}"));
"}";
assertThat(after, is(expectedString.replace("\n", 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.

We should try to find a consistent way to handle the line-separator cross-platform issue, so that we are not cluttering the code too much.

@dvlato dvlato force-pushed the styx-tests-should-pass-in-windows branch from 5d3f05d to fe49cd1 Compare March 12, 2018 17:52
dvlato pushed a commit to dvlato/styx that referenced this pull request Mar 12, 2018
@dvlato dvlato force-pushed the styx-tests-should-pass-in-windows branch from 520850d to b75371d Compare March 14, 2018 17:03
@mikkokar mikkokar merged commit 4f66062 into ExpediaGroup:master Mar 15, 2018
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.

4 participants