Skip to content

Conversation

@agrn
Copy link
Contributor

@agrn agrn commented Jun 4, 2020

Commit 5a661e4 ("repo: fix repo generation when an exercise has multiple subdirectories", 2020-05-26) fixed the issue #305, but it did not add any regression test to the test suite to ensure that the behaviour of `learn-ocaml build' stayed correct.

This series cleans up a bit runtests.sh, adds such a test, and makes Travis to check `learn-ocaml build' against learn-ocaml-corpus.

This patch series keeps the general behaviour of runtests.sh -- perhaps in the future, it could be changed to have a TAP-compliant output, or allow it to run without docker?

Copy link
Collaborator

@erikmd erikmd left a comment

Choose a reason for hiding this comment

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

Thanks @agrn ;

LGTM, one remark though: there are several occurrences of the pattern

for CORPUS in $(find ./corpuses -mindepth 1 -maxdepth 1 -type d) ; do …; done

but this won't work if ever there is a folder that contains a space (I know this is a priori not the case, but better safe than sorry)

so as suggested in https://mywiki.wooledge.org/BashFAQ/024#Workarounds you may want to phrase your loops like this:

while IFS= read -r CORPUS; do …; done < <(find ./corpuses -mindepth 1 -maxdepth 1 -type d)

BTW feel free to write your bash variable names as lowercase: corpus i/o CORPUS, as by convention, lowercase variables are not intended to be exported as environment variables, and won't thereby clash with (uppercase) environment variables :)

@agrn
Copy link
Contributor Author

agrn commented Jun 5, 2020 via email

pushd "$dir" > /dev/null

echo "---> Doing $DIR:"
echo "---> Doing $dir:"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
echo "---> Doing $dir:"
echo "---> Entering $dir:"

@yurug
Copy link
Collaborator

yurug commented Jun 5, 2020

This looks great to me.

Did you try to run shellcheck on your script?

@agrn
Copy link
Contributor Author

agrn commented Jun 5, 2020

Yes, it reports the usual errors with pushd/popd, let, and backslashes in strings. Other than that, there is also the only for loop that I did not convert -- for some reason, when converted to a while loop, it will execute only for the first file found. I am not sure why it behaves like this.

agrn added 3 commits June 5, 2020 15:33
This splits the big for-loop into subroutines to improve the
readability of the script.  Variables are also quotted to avoid
issues.  Most variables are also renamed to be in lowercase, and for
loops replaced by while loops to be more reliable.

Signed-off-by: Alban Gruin <[email protected]>
To check for regressions for the issue ocaml-sf#305 fixed by 5a661e4 ("repo:
fix repo generation when an exercise has multiple subdirectories",
2020-05-26), this adds an optional test that builds repositories found
in tests/corpuses/.  No such repository are provided as-is here, but a
CI pipeline may want to clone a corpus (eg. `learn-ocaml-corpus') in
this directory.

Signed-off-by: Alban Gruin <[email protected]>
…n-ocaml-corpus

The previous commit added a mechanism to try to build repositories
found in tests/corpuses/.  This adds a directive in .travis.yml to
clone learn-ocaml-corpus, so `lean-ocaml build' can be tested by the
CI.

Signed-off-by: Alban Gruin <[email protected]>
Copy link
Collaborator

@erikmd erikmd left a comment

Choose a reason for hiding this comment

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

LGTM.

@agrn

there is also the only for loop that I did not convert

Granted, but fortunately the loop at stake only deal with *.ml files which (by definition) contain no space:

for tosend in $(find . -name "*.ml" -type f -printf "%f\n")

So keeping the PR as is is very OK I guess.

@erikmd erikmd mentioned this pull request Jun 29, 2020
@yurug
Copy link
Collaborator

yurug commented Jun 29, 2020

Thanks!

@yurug yurug merged commit b3d0e75 into ocaml-sf:master Jun 29, 2020
@erikmd erikmd deleted the ag/add-tests branch June 29, 2020 16:17
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