Skip to content

Added pig-latin exercise and Windows Testing Notes #319

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

Merged
merged 2 commits into from
Jul 19, 2017

Conversation

sacherjj
Copy link
Contributor

@sacherjj sacherjj commented Jul 17, 2017

Implementation of the pig-latin exercise. This is much less of a mess than my last pull request. Not sure if difficultly level (2) is right in the JSON. Someone that has more experience where this would fit in might tweak that value, before going live.

I also added a file in _test with instructions for running check-exercises.sh for Windows Rust users. This includes setting up the Ubuntu on Windows sub system and testing against Windows file system hosted files. With this, I was able to run tests to completion on WIndows.

@petertseng
Copy link
Member

petertseng commented Jul 17, 2017

Thanks. It is not yet known when I will have time to review the code, but a reasonable estimate would be sometime between 27 to 48 hours from now (it doesn't have to be me, so feel free to proceed if someone else reviews it).

I would ask that the _test/WINDOWS_README.md be added in its own separate commit (can be a second commit on this PR, or a second PR, your choice) please. It is a separate change from adding pig-latin, and a separate change deserves a second commit.

Feel free to ask for help if you need advice on how to do that. The ways I can think of off the top of my head:

  • git reset 0a6e7169076eb015e6baee2998fdac6ec55f0ccb; git add exercises/pig-latin; git commit; git add _test/README_WINDOWS.md; git commit
  • git rm _test/README_WINDOWS.md; git commit; git revert HEAD; git rebase -i 0a6e7169076eb015e6baee2998fdac6ec55f0ccb then squash the rm commit into the "Added pig latin exercise", and give a message like "add Windows testing instructions" to the revert commit
  • Feel free to use your preferred method of achieving this if you have one that is not listed here; the exact process is not important just the end result.

@petertseng
Copy link
Member

Not sure if difficultly level (2) is right

Historically, this track has only used difficulties 1, 4, 7, and 10, corresponding to the four sections (Introduction = 1, Getting Rusty = 4, Rust Gets Strange = 7, Putting it all Together = 10) in https://github.com/exercism/rust/blob/aea470a76a9c6f0005adebb2a00d969512da3b6e/problems.md. That file does not exist anymore as it has been replaced with https://github.com/exercism/rust/blob/master/problem_ordering.md . So we are not restricted to only doing 1 4 7 10. But you would be breaking new ground.

So if you think it is 2, all I will ask is that you think pig-latin is harder than the exercises with difficulty 1 and easier than the exercises with difficulty 4. If you think so, I trust your judgment in calling it a 2.

@sacherjj
Copy link
Contributor Author

sacherjj commented Jul 17, 2017

I'll have to look through the others in difficulty. I've only done the first 10 or so using exercism. I just figured I could get as much practice by making working exercises and help others at the same time, if I picked the easier one. :)

I think this would fit within the 4 difficulty, with combination of regex. I'll get this into two commits with that change.

And I'm doing my other exercises in their own branch, so I hope to keep cleaner.

@sacherjj
Copy link
Contributor Author

sacherjj commented Jul 17, 2017

I think that is in a good situation now. This has been a little frustrating, but a learning experience. Not unlike the process of learning Rust. Thanks for the help.

Edit: Take two. Lets see if tests for this time. I missed adding .json to the pig-latin commit before.

Copy link
Member

@petertseng petertseng left a comment

Choose a reason for hiding this comment

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

I missed adding .json to the pig-latin commit before.

Probably my bad, I missed config.json in my instructions, sorry about that.

This has been a little frustrating, but a learning experience.

Hoping what you learned will be useful in future open source contributions should you choose to continue to them (this project or others).

Looking pretty good, a number of changes I have to suggest. Feel free to make the changes by amending the existing commits (don't have to be new commits), I'll be able to diff against what I already reviewed.

@@ -0,0 +1,52 @@
# check_exercises.sh for Windows Rust Developers

It is possible to run `check-exercises.sh` on Windows 10, pointing to the Windows location for you GitHub repository. This is done with the Ubunuto on Windows subsystem.
Copy link
Member

Choose a reason for hiding this comment

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

although it (Ubuntu) is spelled correctly below, not here

@@ -0,0 +1,52 @@
# check_exercises.sh for Windows Rust Developers

It is possible to run `check-exercises.sh` on Windows 10, pointing to the Windows location for you GitHub repository. This is done with the Ubunuto on Windows subsystem.
Copy link
Member

Choose a reason for hiding this comment

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

Probably "your GitHub repository" rather than "you"

It is possible to run `check-exercises.sh` on Windows 10, pointing to the Windows location for you GitHub repository. This is done with the Ubunuto on Windows subsystem.

## Enable Developer Mode
To run Ubunutu on Windows, you need to be in Developer Mode.
Copy link
Member

Choose a reason for hiding this comment

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

although it (Ubuntu) is spelled correctly below, not here


## Install

Start a PowerShell as Administartor.
Copy link
Member

Choose a reason for hiding this comment

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

Administrator


This will redownload and build any crates needed, as they only existed in your Windows Rust.


Copy link
Member

Choose a reason for hiding this comment

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

I think I would remove these extra newlines (leaving just one trailing newline at the end of the file)

@@ -660,6 +660,16 @@
]
},
{
"uuid": "c21c379b-fb23-449b-809a-3c6ef1c31221",
"slug": "pig-latin",
Copy link
Member

Choose a reason for hiding this comment

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

Since the exercises will be delivered in the order the appear in this exercises array, it seems to make the most sense to move this exercise somewhere with the other difficulty 4 exercises.


## Source

Rust System: Tyler Long
Copy link
Member

Choose a reason for hiding this comment

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

this README will probably get regenerated, which means this custom content will get lost (it will simply become the info located at https://github.com/exercism/problem-specifications/blob/master/exercises/pig-latin/metadata.yml ). I don't need you to do anything about this, just letting you know it will happen. (Your name will remain in the Cargo.toml though)

@@ -0,0 +1,8 @@
[package]
name = "pig-latin"
version = "0.1.0"
Copy link
Member

Choose a reason for hiding this comment

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

since this exercise complies with https://github.com/exercism/problem-specifications/blob/master/exercises/pig-latin/canonical-data.json which is version 1.0.0, could you change this version here to 1.0.0?

It is not your fault that you did not know to do this, since this track has failed to document it (#278 (comment))

authors = ["sacherjj <[email protected]>"]

[dependencies]
regex = "0.2"
Copy link
Member

Choose a reason for hiding this comment

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

since it is not necessarily the case that any student's solution will use either regex or lazy_static, could you move these dependencies to a file named Cargo-example.toml? See https://github.com/exercism/rust/blob/master/exercises/alphametics/Cargo-example.toml versus https://github.com/exercism/rust/blob/master/exercises/alphametics/Cargo.toml for an example. Otherwise, a student may see these dependencies and not know what to do with them, or think that using them is mandatory and that would unintentionally narrow the kinds of solutions we might see submitted.

[root]
name = "pig-latin"
version = "0.1.0"
dependencies = [
Copy link
Member

Choose a reason for hiding this comment

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

related to the move to Cargo-example.toml, I would make the Cargo.lock based off of an empty dependencies in Cargo.toml so that the student does not see dependencies that they might not use

@sacherjj
Copy link
Contributor Author

sacherjj commented Jul 19, 2017

Well I thought I did that as amending, but ran into a conflict. Not sure how I got two commits. I think the changes are all there. Let me know if I need to run some commands to fix this. Worried that if I do anything, I'll make it worse.

Copy link
Contributor

@ijanos ijanos left a comment

Choose a reason for hiding this comment

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

looks good to me. thank you!

@sacherjj
Copy link
Contributor Author

Thanks for the help Peter. I'll try to make this smoother next time. 👍

@petertseng
Copy link
Member

petertseng commented Jul 19, 2017

Well I thought I did that as amending, but ran into a conflict. Not sure how I got two commits

It looks like all changes you made (changes to both the pig-latin exercise and the Windows instructions) got amended into the Windows instructions commit. At that point, your local history looks like:

M-A-B

M is exercism's master, A is your pig-latin commit, B is your amended windows commit (which includes pig-latin changes)

Your origin/master (your fork) looks like this:

M-A-B'

M and A are the same, but B' is the unamended version of your Windows README.

When you merge with origin/master, you get:

    B'
   /  \
M-A    merge
   \  /
    B

There is a merge conflict here because B and B' are trying to do two different things to _test/README_WINDOWS.md.

When amending a commit, it naturally causes a conflict when merging with the upstream branch (the amended commit and unamended commit are doing two different things to the same files), so you do not merge with the upstream branch, you should simply overwrite it, so that it looks like M-A-B.

I think the changes are all there.

👍 Yup.

It also would make sense for pig-latin changes to get amended into the pig-latin commit, instead of into the Windows README commit, because they are separate changes and the changes should go to the appropriate commits.

A possible way to achieve this would be to do a similar procedure as we did before: git reset 0a6e7169076eb015e6baee2998fdac6ec55f0ccb; git add config.json; git add exercises/pig-latin; git commit; git add _test/README_WINDOWS.md; git commit; git push --force-with-lease.
(0a6e716 is the M in the above diagrams. I deterined this by looking at git log on this branch and it was the latest commit that was not made by you (not in this pull request))

Another way would have to initially make the updates to pig-latin in a separate commit, and the updates to the README_WINDOWS in another separate commit, then git rebase -i 0a6e7169076eb015e6baee2998fdac6ec55f0ccb) and squash the commits so that there is one commit for pig-latin and one commit for README_WINDOWS.

Worried that if I do anything, I'll make it worse.

If you do make it worse, it is always possible to return to the previous state. I noted at the time that the commit made was 91a1009, so it would have been possible to do git reset --hard 91a100936def5f5fa5ce919ea3cdfdc00e63f657 to return to that state.

@petertseng petertseng merged commit e290813 into exercism:master Jul 19, 2017
@petertseng
Copy link
Member

Thanks for the new exercise and the testing instructions.

I moved the changes into two commits. The disadvantage is that you don't get the practice of doing so. If you are interested in doing that, you may feel free to recreate the situation, I imagine it would be something like:

git checkout -b testconflicts
echo acontents > a
git add a
git commit
echo bcontents > b
git add b
git commit
git push -u origin testconflicts
echo addsomethingtoa >> a
echo completelychangeb > b
git commit -a --amend

At this point, you would get a conflict if you git pull or git merge origin/testconflicts. Thus you do not want to run either of those commands, you want to git push --force-with-lease.

It may also be useful to cause the conflict (run git pull), and fix it (I suggest using git reset with similar procedures as what I described above)

@petertseng
Copy link
Member

Now I wonder whether there are any topics that can be added. lack of topics causes extra newline in #322. probably something to do with strings. shrug

@petertseng
Copy link
Member

I forgot to ask for an empty src/lib.rs file (#270)

@sacherjj
Copy link
Contributor Author

.gitignore would need to be modified for src/lib.rs. It currently has all of src ignored.

@petertseng
Copy link
Member

indeed, I would remove src from gitignore.

petertseng pushed a commit that referenced this pull request Jul 23, 2017
Forgot to be added in #319.
Should be added because of #270.
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