-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix test runner #22
Fix test runner #22
Conversation
Thanks @2Grey :) @ErikSchierboom will take a look at this on Tuesday if no-one else gets to it first! |
@@ -1 +1,2 @@ | |||
test/output | |||
.github/ | |||
tests/ |
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.
The tests are passed to the test scripts via a volume mount, but they don't have to be present when building the Dockerfile. Having them here has the benefit of being able to change the tests without having to rebuild the Docker image.
@@ -1,42 +1,51 @@ | |||
# Exercism Swift Test Runner |
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.
I've updated this file to make it similar to existing test runner READMEs, which was needed because I change the test script files to be consistent too.
# build docker image | ||
docker build --rm --no-cache -t swift-test-runner . | ||
|
||
docker run \ |
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.
There were several options missing here, including a key one: --network none
. Other test runners have this file named run-all-tests-in-docker
, so I've renamed the file and added the right flags that match how the test runner is actually run on the website.
bin/run-in-docker.sh
Outdated
echo "usage: run-in-docker.sh exercise-slug ./relative/path/to/solution/folder/ ./relative/path/to/output/directory/" | ||
printHelpAndExit() { | ||
echo -e "${ORANGE}USAGE${NC}" | ||
echo -e " ./run-in-docker.sh ${GREEN}-s${NC} two-fer ${GREEN}-i${NC} /absolute/path/to/solution/folder/ ${GREEN}-o${NC} ./absolute/path/to/output/directory/" |
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.
I've converted the relative paths to absolute paths as there is no guarantee that the path is relative (see https://github.com/exercism/docs/blob/main/building/tooling/test-runners/docker.md) and in fact it is more likely for it to be absolute.
bin/run-in-docker.sh
Outdated
# build docker image | ||
docker build --rm --no-cache -t swift-test-runner . | ||
docker build --rm --no-cache -t exercism/swift-test-runner . |
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.
This is the actual name we use for the test runner, so adding the prefix ensure that the local development environment uses this built version.
bin/run-in-docker.sh
Outdated
--network none \ | ||
--read-only \ | ||
--mount type=bind,src="${INPUT_DIR}",dst=/solution \ | ||
--mount type=bind,src="${OUTPUT_DIR}",dst=/output \ | ||
--mount type=volume,dst=/tmp \ |
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.
Add the proper flags here
bin/run-tests-in-docker.sh
Outdated
--network none \ | ||
--read-only \ | ||
--mount type=bind,src="${PWD}/tests",dst=/opt/test-runner/tests \ | ||
--mount type=volume,dst=/tmp \ | ||
--workdir /opt/test-runner \ | ||
--entrypoint /opt/test-runner/bin/run-tests.sh \ |
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.
Added the proper flags here
# echo "-------------" | ||
RUNALL=true "${BASEDIR}"/TestRunner --slug "${SLUG}" --solution-directory "${INPUT_DIR}/${SLUG}" --output-directory "${OUTPUT_DIR}" --swift-location $(which swift) --build-directory "/tmp/" | ||
|
||
RUNALL=true "${BASEDIR}"/TestRunner --slug "${SLUG}" --solution-directory "${INPUT_DIR}" --output-directory "${OUTPUT_DIR}" --swift-location $(which swift) --build-directory "/tmp" |
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.
I've removed the /${SLUG}
argument from the solution directory as the solution directory should be the argument that is passed in.
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.
Thanks so much for fixing the test runner. I've done a bit of work to get the test runner to adhere to the spec fully, but it has succeeded!
- '.gitignore' | ||
- 'LICENSE' | ||
- '**.md' | ||
- main |
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.
We renamed the branch to main
.DS_Store | ||
**/.build | ||
**/Packages | ||
**/Package.resolved | ||
**/*.xcodeproj | ||
bin/TestRunner |
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.
We usually don't store binaries in our repos
# $1: exercise slug | ||
# $2: absolute path to solution folder | ||
# $3: absolute path to output directory |
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.
I've changed this file to take positional arguments as that is how the interface requires it.
Let me know if there is anything you want to know about the commits I added. |
Fixes for #21
Runs
Direct launch of TestRunner
Result
Script run of TestRunner
Result