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

feat: Add Windows support #591

Merged
merged 7 commits into from
Aug 16, 2021
Merged

feat: Add Windows support #591

merged 7 commits into from
Aug 16, 2021

Conversation

slarse
Copy link
Collaborator

@slarse slarse commented Aug 13, 2021

fix #589, fix #335

Partially addresses #273

This PR adds core support for Windows, along with a Windows build in the CI. Note that statistics gathering, targeted repair and segment mode tests are not passing: they are currently disabled on Windows.

@slarse
Copy link
Collaborator Author

slarse commented Aug 13, 2021

There appears to be a few problems in the test suite, but the core functionality now works for Windows.

Interestingly, the errors seen on GitHub do not occur on my own Windows machine. @algomaster99 could you try running the tests of this branch on your Windows machine and see what happens?

@slarse slarse added the WiP label Aug 13, 2021
@algomaster99
Copy link
Member

@algomaster99 could you try running the tests of this branch on your Windows machine and see what happens?

I will check it by tonight.

@slarse
Copy link
Collaborator Author

slarse commented Aug 13, 2021

I will check it by tonight.

No hurry, do it when you've got time.

@algomaster99
Copy link
Member

@slarse I was able to repair the files which @PrakashNayak provided. However, the tests are failing on my system too.

[ERROR] Tests run: 434, Failures: 5, Errors: 7, Skipped: 2
[ERROR] Errors: 
[ERROR]   ClasspathModeTest.resolveClasspathFrom_enablesRepairOfViolation_thatRequiresClasspathToDetect:47 » NonZeroExit
[ERROR]   GatherStatsTest.statisticsFile_containsCorrectNbViolationsBeforeAndAfter_whenUsingTargetedRepair:93->performTargetedRepair:159 » NonZeroExit
[ERROR]   GatherStatsTest.statisticsFile_containsCorrectSpecifierForPerformedRepair_whenUsingTargetedRepair:120->performTargetedRepair:159 » NonZeroExit

[ERROR]   GatherStatsTest.statisticsFile_containsExpectedStats:48 » NonZeroExit
[ERROR]   MavenLauncherTest.sorald_repairsProductionAndTestCode_inMavenProject:53 » NonZeroExit
[ERROR]   MavenLauncherTest.sorald_repairsRuleViolation_thatRequiresClasspathToDetect:91 » NonZeroExit
[ERROR]   WarningMinerTest.canDetectRuleViolation_thatRequiresClasspath_whenResolvingClasspathInMavenProject:214 » NonZeroExit

Failures have long messages so let me know if you need me to send it you.

@slarse
Copy link
Collaborator Author

slarse commented Aug 16, 2021

Those are similar errors to CI but not the same:

2021-08-13T14:34:10.6039028Z [INFO] Results:
2021-08-13T14:34:10.6039821Z [INFO] 
2021-08-13T14:34:10.6043146Z [ERROR] Failures: 
2021-08-13T14:34:10.6044495Z [ERROR]   SegmentStrategyTest.segmentStrategy_doesNotFail_onCrashInParsingSegment:115 
2021-08-13T14:34:10.6046462Z Expected: a value greater than <1>
2021-08-13T14:34:10.6047116Z      but: <0> was less than <1>
2021-08-13T14:34:10.6047678Z [ERROR] Errors: 
2021-08-13T14:34:10.6053121Z [ERROR]   GatherStatsTest.statisticsFile_containsCorrectNbViolationsBeforeAndAfter_whenUsingTargetedRepair:93->performTargetedRepair:155 � IndexOutOfBounds
2021-08-13T14:34:10.6057540Z [ERROR]   GatherStatsTest.statisticsFile_containsCorrectNbViolationsBeforeAndAfter_whenUsingTargetedRepair:93->performTargetedRepair:155 � IndexOutOfBounds
2021-08-13T14:34:10.6060624Z [ERROR]   GatherStatsTest.statisticsFile_containsCorrectNbViolationsBeforeAndAfter_whenUsingTargetedRepair:93->performTargetedRepair:155 � IndexOutOfBounds
2021-08-13T14:34:10.6064253Z [ERROR]   GatherStatsTest.statisticsFile_containsCorrectSpecifierForPerformedRepair_whenUsingTargetedRepair:120->performTargetedRepair:155 � IndexOutOfBounds
2021-08-13T14:34:10.6070875Z [ERROR]   GatherStatsTest.statisticsFile_containsCorrectSpecifierForPerformedRepair_whenUsingTargetedRepair:120->performTargetedRepair:155 � IndexOutOfBounds
2021-08-13T14:34:10.6074830Z [ERROR]   GatherStatsTest.statisticsFile_containsCorrectSpecifierForPerformedRepair_whenUsingTargetedRepair:120->performTargetedRepair:155 � IndexOutOfBounds
2021-08-13T14:34:10.6077360Z [ERROR]   TargetedRepairTest.targetedRepair_acceptsAbsoluteViolationPath:113 � NonZeroExit
2021-08-13T14:34:10.6080299Z [ERROR]   TargetedRepairTest.targetedRepair_canTargetSpecificFile:169 � NonZeroExit
2021-08-13T14:34:10.6082242Z [ERROR]   TargetedRepairTest.targetedRepair_canUseSpecifiers_withRuleKeysLackingSPrefix:199 � NonZeroExit
2021-08-13T14:34:10.6091255Z [ERROR]   TargetedRepairTest.targetedRepair_correctlyRepairsSingleViolation:38 � NonZeroExit
2021-08-13T14:34:10.6094292Z [ERROR]   TargetedRepairTest.targetedRepair_requiresViolationSpecs_pointToExistingViolations:135 � IllegalArgument
2021-08-13T14:34:10.6098511Z [INFO] 
2021-08-13T14:34:10.6103883Z [ERROR] Tests run: 434, Failures: 1, Errors: 11, Skipped: 2

Some of the errors you get are most likely due to not having Maven on the system path (I get those on my machine). The creation of the statistics file also appears not to work, and the violation specifier appears a bit broken.

@slarse
Copy link
Collaborator Author

slarse commented Aug 16, 2021

To as quickly as possible add at least partial support for Windows, I'm just ignoring the test failures. The vast majority of functionality seems to be working fine.

@algomaster99
Copy link
Member

algomaster99 commented Aug 16, 2021

Probably. I have manually updated PATH variable to include mvn executable and that works on Powershell.

On Windows, there is a difference between the system path and the user path. When using Python's subprocess module, I've found that it does not recognize programs on the user path, but only on the system path. Might be the same thing for Java.

@slarse
Copy link
Collaborator Author

slarse commented Aug 16, 2021

Ping @fermadeiral @khaes-kth, ready for review/merge

Copy link
Collaborator

@khesoem khesoem left a comment

Choose a reason for hiding this comment

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

LGTM.

@khesoem khesoem merged commit 1597378 into master Aug 16, 2021
@khesoem khesoem deleted the issue/273-add-windows-support branch August 16, 2021 12:15
@@ -52,6 +56,7 @@ jobs:
restore-keys: ${{ runner.os }}-sonar

- name: Check formatting with spotless
if: ${{ matrix.os == 'ubuntu-latest' }}
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this if condition, we can probably set core.eol to lf in a .gitattributes file so that spotless doesn't change the line endings while formatting. This should be done when we decide that sorald should support development on Windows too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's not a full solution, as if we fully support Windows, we also need to have files with CRLF line endings in our test resources. To test the sniper printer output, that is. We literally need Git not to change line endings or the tests break.

That being said, we could of course just set core.autocrlf false in a checked-in .gitattributes file.

Copy link
Member

Choose a reason for hiding this comment

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

we also need to have files with CRLF line endings in our test resources. To test the sniper printer output, that is.

Right. I did not consider this. 😅

@slarse slarse mentioned this pull request Aug 17, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Existing Sorald code is not generating remediated code Hi I am facing this issue while using repair command
3 participants