-
-
Notifications
You must be signed in to change notification settings - Fork 365
Added DifferenceOfSquares Test Generator #442
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
Conversation
@felix91gr Just to be safe: did you run the test generator project? That is, did you run What you should do is to rebase your branch on the latest master and then try to run the generator again. If there is no compile error, the test generator should run. Usually, the test file generated by the newly added generator is slightly different from what it was, which I can confirm is the case once you have done the rebase and re-run the generator. When the generated tests file is different, you have to check to see if the example and default (stub) implementation of that exercise are still correct. You can verify that my running the build script (build.ps1 or build.sh, depending on your operating system). If you have any further questions, feel free to ask! |
No, I didn't, I didn't know. I should've asked. What I did do was run
Ohhh, I see. Thanks! I'll rebase it first then :)
I will! Thank you so much :) |
I did the rebase. But I don't know if the PR now works... this Starbucks' internet flaked out and I think NuGet needs a stable connection to work. NuGet gets invoked when I write Anyhow... when I'm back home I'll fix it if it doesn't work :) |
dotnet run indeed needs an internet connection as it is downloading the Nuget packages. Having the Travis build pass is not enough unfortunately, as it currently does not run the generators project. Good luck fixing things and we really appreciate the help! |
Now I ran What should I check next before the merge? EditI was re-reading your first response, and I think you already answered this question :P
I'm doing so as we speak! :) Edit 2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felix91gr Aha, progress! I can now see the updated DifferenceOfSquaresTest.cs
file, so your generator is working. There are a couple of issues that cause your build to fail:
- By running
dotnet run
, all generators run and some other exercises have had their test data updated leading to update test files. The updated data could very well break the existing example. This is actually my fault, as I should have mentioned the option to run the generator for a single exercise by using the-e
parameter. Hence, instead of runningdotnet run
, you should rundotnet run -e difference-of-squares
. This will ensure that only the difference of squares test generator is being run.
For this PR, you should remove the files not directly related to your new test generator. That means the following files should be removed:exercises/largest-series-product/LargestSeriesProductTest.cs
,exercises/pig-latin/PigLatinTest.cs
,exercises/sum-of-multiples/SumOfMultiplesTest.cs
,generators/Exercises/Clock.cs
(which should not be there due to the rebase). - As you can see in the diff, the updated
DifferenceOfSquaresTest.cs
file expects a different API than the current implementation. Whereas previously the tested methods were part of a class namedSquares
, the updated API expects it to be calledDifferenceOfSquares
. You should rename the example and stub implementation files to match the updated class name,
With the above changes, I think your PR will be done!
I changed and tested the test generator and the tests generated. Git didn't let me work without automatically changing the files that have But everything else worked just fine :) Btw: I changed the name of the class in the test to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see that you changed the name of the test generator class, but that won't work as the test generator name has to match the exercise name. So could you revert this back to DifferenceOfSquares? You should then modify the example and stub implementation's class names, as explained in my previous comment. Good luck!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, could you remove all files not related to the DifferenceOfSquares exercise from the PR?
Yeah, sure! :)
I'm not sure. The problem lies within the |
🤔 do we have a git attributes file? It seems we could streamline the |
I'm off to bed now. I'll have some tips how to deal with the git issues tomorrow! |
Speaking of this:
🤔 we might have to change the Let me explain: using the name DifferenceOfSquares for the class isn't allowed, as the class has a member with the same name: public static int DifferenceOfSquares(int max)
{
throw new NotImplementedException("You need to implement this function.");
} With the class being named the same as this method, I get the following error while running DifferenceOfSquares.cs(19,23): error CS0542: 'DifferenceOfSquares': member names cannot be the same as their enclosing type [/home/felix/Documents/Programming/exercism/csharp/build/difference-of-squares/DifferenceOfSquares.csproj] And if I have understood the framework correctly, the method name can't change unless the property name described in the What do you think? Should we keep the Tester Generator being named |
Excellent question. In general, we never modify the canonical data itself (which we don't control), we just modify our internal representation (which we do control). An example of this is the test generator for the leap exercise, which changes the tested method to a different name by overriding the public class Leap : Exercise
{
protected override void UpdateCanonicalData(CanonicalData canonicalData)
{
foreach (var canonicalDataCase in canonicalData.Cases)
canonicalDataCase.Property = "IsLeapYear";
}
} I think in our case we have two options:
If you agree with me and go for option 2, you should be able to do this using the same approach used in the
We do have a .gitattributes file, and I thought that this worked well on my Mac. I'll have to check another time.
You shouldn't change the files themselves, you should just use git to revert them to their original version. You can do this using git remote add exercism https://github.com/exercism/csharp
git fetch exercism
git rebase exercism/master You can skip the first line if you already have add the We then reset the files we don't want to the version in the exercism remote: git checkout exercism/master exercises/largest-series-product/Example.cs
git checkout exercism/master exercises/largest-series-product/LargestSeriesProductTest.cs
git checkout exercism/master generators/Exercises/Clock.cs
git add exercises/largest-series-product/Example.cs
git add exercises/largest-series-product/LargestSeriesProductTest.cs
git add generators/Exercises/Clock.cs
git commit --amend
git push --force This should remove the changes in those files from your PR. As long as you never run |
Awesome explanation! I get it better now, and I completely agree. I'll do that.
Hmm. It looks like the ~/D/P/exercism $ git clone https://github.com/exercism/csharp/ csharp_original
# blablabla
~/D/P/exercism $ cd csharp_original/
~/D/P/e/csharp_original (master) $ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: exercises/largest-series-product/Example.cs
modified: exercises/largest-series-product/LargestSeriesProductTest.cs
no changes added to commit (use "git add" and/or "git commit -a")
~/D/P/e/csharp_original (master) $ git add .
warning: CRLF will be replaced by LF in exercises/largest-series-product/Example.cs.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in exercises/largest-series-product/LargestSeriesProductTest.cs.
The file will have its original line endings in your working directory. Git's messages are a bit ambiguous here. But I think I'm understanding them allright 🤔 The What do you think? |
As long as we choose one, for consistency, I don't really think it matters. https://help.github.com/articles/dealing-with-line-endings/ |
@felix91gr Okay, we'll solve the git issue in another issue. Could you cleanup this PR as requested (to remove the extra files)? |
Awesome!
And yes, I will :)
I’ll be back in a couple of days: atm, I’m kinda busy and also kinda sleep
deprived xD
I hope I’ll be back by... Wednesday, or so.
See ya!
…On Mon, Oct 2, 2017 at 3:07 AM Erik Schierboom ***@***.***> wrote:
@felix91gr <https://github.com/felix91gr> Okay, we'll solve the git issue
in another issue. Could you cleanup this PR as requested (to remove the
extra files)?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#442 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ALNBJ0HH3xmDfD-VxOhLvKZTYNZxpNXDks5soH2bgaJpZM4Pnug->
.
|
@ErikSchierboom - I'm with @jpreese and as long as we have consistent way of doing things that sounds good to me! I use Windows and every editor that I know renders |
I've created an issue for the line-ending issue: #452 |
Did you need any help with this @felix91gr ? |
🤔 I shouldn’t be having more git issues, and therefore this PR should be
streamlined from now on.
I’ll try to finish it during this week... I’ll ask you for help if I’m
stuck ^^
…On Mon, Oct 9, 2017 at 10:12 PM John Reese ***@***.***> wrote:
Did you need any help with this @felix91gr <https://github.com/felix91gr>
?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#442 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ALNBJ0bSw0G6x-BlZOTbsi9956LUF1mjks5sqsSSgaJpZM4Pnug->
.
|
I deleted my fork and started over again. I will link to this PR as reference from a new PR |
You can push your changes to the same branch -- no need to close and open a new PR. |
Yeah... but I messed up too many things:
I get what you mean. But I really would prefer to start this one again clean. |
- Changed name of class for exercise from Squares to DifferenceOfSquares, as per the standards - Changed names of methods generated in tests to fit restrictions of naming in C# (see PR exercism#442) - Changed names of methods required in exercise to fit new names generated in tests
- Changed name of class for exercise from Squares to DifferenceOfSquares, as per the standards - Changed names of methods generated in tests to fit restrictions of naming in C# (see PR exercism#442) - Changed names of methods required in exercise to fit new names generated in tests
- Changed name of class for exercise from Squares to DifferenceOfSquares, as per the standards - Changed names of methods generated in tests to fit restrictions of naming in C# (see PR exercism#442) - Changed names of methods required in exercise to fit new names generated in tests
- Changed name of class for exercise from Squares to DifferenceOfSquares, as per the standards - Changed names of methods generated in tests to fit restrictions of naming in C# (see PR exercism#442) - Changed names of methods required in exercise to fit new names generated in tests
- Changed name of class for exercise from Squares to DifferenceOfSquares, as per the standards - Changed names of methods generated in tests to fit restrictions of naming in C# (see PR #442) - Changed names of methods required in exercise to fit new names generated in tests
Thank you @jpreese for the help :)
I think I'm starting understand the basics of how the Exercises framework works :D