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

test files: rename xxx_test.sh to xxx.bats, fix shebang #541

Merged
merged 4 commits into from Sep 17, 2021

Conversation

braoult
Copy link
Contributor

@braoult braoult commented Sep 15, 2021

tests scripts: change extension to .bats, fix shebang.


Reviewer Resources:

Track Policies

braoult added a commit to braoult/exercism-bash-test-runner that referenced this pull request Sep 16, 2021
This patch includes Glennj's:
    exercism#25

And also includes expected_results.json fixes, as requested by Glenn on Slack:
    3 spaces is fine. Just fix the expected results file to add the
    missing space. Don’t change anything else.
braoult added a commit to braoult/exercism-bash-test-runner that referenced this pull request Sep 16, 2021
braoult added a commit to braoult/exercism-bash-test-runner that referenced this pull request Sep 16, 2021
iHiD
iHiD previously requested changes Sep 16, 2021
Copy link
Member

@iHiD iHiD left a comment

Choose a reason for hiding this comment

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

This shouldn't get merged until exercism/bash-test-runner#27 is merged

We need to be careful on this. The test runner most support both existing exercises and this new format, and that support must be deployed, before this is merged.

I'm "Requesting Changes" just to block this until the test runner is merged.

@iHiD
Copy link
Member

iHiD commented Sep 16, 2021

@angelikatyborska, @neenjaw, @mpizenberg Any advice on this after doing it on your tracks?

(Thank you btw @braoult)

@braoult
Copy link
Contributor Author

braoult commented Sep 16, 2021

We need to be careful on this. The test runner most support both existing exercises and this new format, and that support must be deployed, before this is merged.

exercism/bash-test-runner#27 supports both old (xxx_test.sh) and new (xxx.bats) file names. And yes, this PR was planned to be hold until bash-test-runner PR is merged.

@mpizenberg
Copy link
Member

tbh I haven't fully taken the time yet to evaluate the implications of the change on the online tooling. The tooling itself in the elm track does not support the old way, only the new one, and the filepaths changes actually occurred a while ago, before starting the work on v3. It's just that I noticed the multiple files issues on the online editor for even older submissions of mine.

@braoult
Copy link
Contributor Author

braoult commented Sep 16, 2021

tbh I haven't fully taken the time yet to evaluate the implications of the change on the online tooling. The tooling itself in the elm track does not support the old way, only the new one, and the filepaths changes actually occurred a while ago, before starting the work on v3. It's just that I noticed the multiple files issues on the online editor for even older submissions of mine.

When I discussed about this change on Slack yesterday, I wondered what could be some other side effects, nobody raised the online tooling (and it did not raise an alarm in my mind too, as I never used it :-) Could this be a blocking point ? I don't know at all how all of this interacts...

@iHiD
Copy link
Member

iHiD commented Sep 16, 2021

The main effect will be that students will get both the bash and the bats files in the editor. The bash ones will be readonly and they'll have to copy their code into the bats ones.

@mpizenberg
Copy link
Member

mpizenberg commented Sep 16, 2021

Well, the online tooling is composed of the tests runner (seems you took care of that), the analyzer (only cares about the solution), the representer (which only cares about the solution, not the tests so fine here) and the online editor, which needs to display the solution (and tests for practice exercises) to the user.

So in you case, I think the only point left is to check how is handled the presentation of the tests file in the online editor for practice exercise.

@braoult
Copy link
Contributor Author

braoult commented Sep 16, 2021

So in you case, I think the only point left is to check how is handled the presentation of the tests file in the online editor for practice exercise.

Yes.

@iHiD, why the bash (student' solution) files would be read-only, and not the batsfiles (tests) ? I am not sure to understand. What we do here is:

  • before :
student solution: xxx.sh
test program: xxx_test.sh
  • after :
student solution: xxx.sh
test program: xxx.bats

@glennj
Copy link
Contributor

glennj commented Sep 16, 2021

The main effect will be that students will get both the bash and the bats files in the editor. The bash ones will be readonly and they'll have to copy their code into the bats ones.

I'm not following: we're renaming the test file. In the editor, which files are available to edit? My current experience is that only the ".files.solution" file is editable, and the ".files.test" file is shown in the right-hand Tests tab. The existing "bats_extra.bats" file (test helper functions) is nowhere to be seen in the editor.

What will students have to copy?

@angelikatyborska
Copy link

@angelikatyborska Any advice on this after doing it on your tracks?

I actually started maintaining the track after this change happened 🤷

@braoult
Copy link
Contributor Author

braoult commented Sep 16, 2021

My concern here is only : Where and when the online editor gets the list of files (solution and test) to edit ?

  • where: Is there some hardcoded names on UI side, or is the list taken from somewhere (likely .meta/config.json ?). If it is taken from config.json, I don't see any issue (I updated them in this PR). If not, I simply have no clue on what should be done there.
  • when : I hope the filenames information is part of the student's solution environment (i.e. the filenames are determined when the student starts to use UI, and never changed later). Does someone here knows how it works, or should I ask in another repo/Slack place, with more knowledge on this part ?

@angelikatyborska
Copy link

where: Is there some hardcoded names on UI side, or is the list taken from somewhere (likely .meta/config.json ?).

It is taken from .meta/config.json, the three types of files - "test", "solution", and "editor" (non-editable files). But added to that are the files that the student submitted for the previous solution. Via the web editor they only could have submitted the previous values of files.solution, but via the CLI anything.

when : I hope the filenames information is part of the student's solution environment (i.e. the filenames are determined when the student starts to use UI

@iHiD will know this best, but my understanding is that every solution contains the git SHA of the exercise as it were when the student started the exercise and takes files directly from git from that point in time. However, it can change. The platform shows when a change is done to an exercise and shows you the diff between your version and the new version. Then, you can choose to update your solution to the newest version and I think that changes the SHA which means the student will now get the newest versions of all files, including the new .meta/config.json.

iHiD pushed a commit to exercism/bash-test-runner that referenced this pull request Sep 17, 2021
@iHiD
Copy link
Member

iHiD commented Sep 17, 2021

OK, a couple of things.

  1. The files are locked to what the student has when they start the exercise, but they are prompted to update when changes are made, at which point they get multiple solution files if the solution file has been renamed. That's because they get all their submitted files, and all the files in the solution key.
  2. I misunderstood and thought that we were renaming the stubs, not the tests. Sorry. The fact that only the tests are changing makes this less of a concern. I'm not sure what happens when a student updates to the latest version then downloads that update. I doubt it will delete their old tests file, so they'll have both. Will that be ok?

I've now merged the test-runner one so remove my lock on this.

@iHiD iHiD self-requested a review September 17, 2021 09:37
@iHiD iHiD dismissed their stale review September 17, 2021 09:37

Test runner merged

@braoult
Copy link
Contributor Author

braoult commented Sep 17, 2021

I'm not sure what happens when a student updates to the latest version then downloads that update. I doubt it will delete their old tests file, so they'll have both. Will that be ok?

Yes: If both files are there, test-runner will use by default the new one (xxx.bats). This is done in bin/run.sh :

    local test_file="${slug//-/_}.bats"
    # test scripts may be (old) xxxx_test.sh
    [[ -f "$test_file" ]] || test_file="${slug//-/_}_test.sh"

As the test code itself is unchanged, we are fine here.

exercises/shared/.docs/tests.md Outdated Show resolved Hide resolved
@glennj
Copy link
Contributor

glennj commented Sep 17, 2021

The workflow is doing this:

gh api repos/exercism/bash/pulls/541/files --paginate --jq '
  .[] |
    select(.status == "added" or .status == "modified" or .status == "renamed") |
    select(.filename |
    match("\\.(sh|bash|bats)$")) |
    .filename
'

And this finds all the renamed test scripts, and the tests all run successfully.

@glennj glennj linked an issue Sep 17, 2021 that may be closed by this pull request
@glennj glennj requested a review from IsaacG September 17, 2021 20:33
@glennj
Copy link
Contributor

glennj commented Sep 17, 2021

@IsaacG I know you have opinions about this subject. Can you review please?

@braoult
Copy link
Contributor Author

braoult commented Sep 17, 2021

@IsaacG I know you have opinions about this subject. Can you review please?

Do you mean the extension itself, as seen on Slack (no extension for executable) ?

@glennj
Copy link
Contributor

glennj commented Sep 17, 2021

Do you mean the extension itself, as seen on Slack (no extension for executable) ?

No, removing the extension will make the pr.yml github workflow harder to make specific.

I am hoping that Isaac can give a review faster than Jeremy.

Copy link
Member

@IsaacG IsaacG left a comment

Choose a reason for hiding this comment

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

This looks good to me! Thank you for your work.

@@ -32,4 +32,4 @@ trap cleanup EXIT
cp "${solution}" "${exercise_name}.sh"

# Run the tests
bats "${exercise_name}_test.sh"
bats "${exercise_name}.bats"
Copy link
Member

Choose a reason for hiding this comment

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

Side note/no change requested. In theory, with the fixed shebang. we should be able to give the tests a +x and just run them ... but in practice calling bats with the filename is probably easier.

Copy link
Contributor Author

@braoult braoult Sep 17, 2021

Choose a reason for hiding this comment

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

Exact. I thought about it, but unsure about this +x on non *ix-like systems... And as I saw solutions (.sh) were non executable, I preferred to change nothing. Someone more aware of this should do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I don't think that exercism download respects the executable bits.

@glennj glennj merged commit 79a2d5a into exercism:main Sep 17, 2021
@braoult braoult deleted the br branch September 17, 2021 23:40
glennj pushed a commit to glennj/exercism-bash-test-runner that referenced this pull request Sep 23, 2021
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.

Should *_test.sh be a bats file?
6 participants