-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add script to run tests * Exclude more files from Docker build context * Run smoke tests in CI * Use tmp dir * Add expected analysis files
- Loading branch information
1 parent
fc82aa0
commit 0ccded9
Showing
30 changed files
with
196 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ node_modules | |
.gitattributes | ||
.dockerignore | ||
Dockerfile | ||
test/ | ||
bin/ | ||
!bin/run.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Synopsis: | ||
# Run the analyzer on a solution using the analyzer Docker image. | ||
# The analyzer Docker image is built automatically. | ||
|
||
# Arguments: | ||
# $1: exercise slug | ||
# $2: path to solution folder | ||
# $3: path to output directory | ||
|
||
# Output: | ||
# Run the analyzer on a solution using the analyzer Docker image. | ||
# The analyzer Docker image is built automatically. | ||
|
||
# Example: | ||
# ./bin/run-in-docker.sh two-fer path/to/solution/folder/ path/to/output/directory/ | ||
|
||
# Stop executing when a command returns a non-zero return code | ||
set -e | ||
|
||
# If any required arguments is missing, print the usage and exit | ||
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then | ||
echo "usage: ./bin/run-in-docker.sh exercise-slug path/to/solution/folder/ path/to/output/directory/" | ||
exit 1 | ||
fi | ||
|
||
slug="$1" | ||
solution_dir=$(realpath "${2%/}") | ||
output_dir=$(realpath "${3%/}") | ||
|
||
# Create the output directory if it doesn't exist | ||
mkdir -p "${output_dir}" | ||
|
||
# Build the Docker image | ||
docker build --rm -t exercism/javascript-analyzer . | ||
|
||
# Run the Docker image using the settings mimicking the production environment | ||
docker run \ | ||
--rm \ | ||
--network none \ | ||
--read-only \ | ||
--mount type=bind,src="${solution_dir}",dst=/solution \ | ||
--mount type=bind,src="${output_dir}",dst=/output \ | ||
--mount type=tmpfs,dst=/tmp \ | ||
exercism/javascript-analyzer "${slug}" /solution /output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Synopsis: | ||
# Test the analyzer Docker image by running it against a predefined set of | ||
# solutions with an expected output. | ||
# The analyzer Docker image is built automatically. | ||
|
||
# Output: | ||
# Outputs the diff of the expected analysis against the actual analysis | ||
# generated by the analyzer Docker image. | ||
|
||
# Example: | ||
# ./bin/run-tests-in-docker.sh | ||
|
||
# Stop executing when a command returns a non-zero return code | ||
set -e | ||
|
||
# Build the Docker image | ||
docker build --rm -t exercism/javascript-analyzer . | ||
|
||
# Run the Docker image using the settings mimicking the production environment | ||
docker run \ | ||
--rm \ | ||
--network none \ | ||
--read-only \ | ||
--mount type=bind,src="${PWD}/test",dst=/opt/analyzer/test \ | ||
--mount type=tmpfs,dst=/tmp \ | ||
--volume "${PWD}/bin/run-tests.sh:/opt/analyzer/bin/run-tests.sh" \ | ||
--workdir /opt/analyzer \ | ||
--entrypoint /opt/analyzer/bin/run-tests.sh \ | ||
exercism/javascript-analyzer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Synopsis: | ||
# Test the analyzer by running it against a predefined set of solutions | ||
# with an expected output. | ||
|
||
# Output: | ||
# Outputs the diff of the expected analysis against the actual analysis | ||
# generated by the analyzer. | ||
|
||
# Example: | ||
# ./bin/run-tests.sh | ||
|
||
exit_code=0 | ||
|
||
# We need to copy the fixtures to a temp directory as the user | ||
# running within the Docker container does not have permissions | ||
# to run the sed command on the fixtures directory | ||
fixtures_dir="test/fixtures" | ||
tmp_fixtures_dir="/tmp/test/fixtures" | ||
rm -rf "${tmp_fixtures_dir}" | ||
mkdir -p "${tmp_fixtures_dir}" | ||
cp -R ${fixtures_dir}/* "${tmp_fixtures_dir}" | ||
|
||
# Iterate over all test directories | ||
for analysis_file in $(find "${tmp_fixtures_dir}" -name expected_analysis.json); do | ||
slug=$(echo "${analysis_file:${#tmp_fixtures_dir}+1}" | cut -d / -f 1) | ||
test_dir=$(dirname "${analysis_file}") | ||
test_dir_name=$(basename "${analysis_file}") | ||
test_dir_path=$(realpath "${test_dir}") | ||
bin/run.sh "${slug}" "${test_dir_path}" "${test_dir_path}" | ||
|
||
file="analysis.json" | ||
expected_file="expected_${file}" | ||
echo "${test_dir}: comparing ${file} to ${expected_file}" | ||
|
||
if ! diff "${test_dir}/${file}" "${test_dir}/${expected_file}"; then | ||
exit_code=1 | ||
fi | ||
done | ||
|
||
exit ${exit_code} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
1 change: 1 addition & 0 deletions
1
test/fixtures/annalyns-infiltration/exemplar/expected_analysis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
1 change: 1 addition & 0 deletions
1
test/fixtures/annalyns-infiltration/optimal/expected_analysis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
1 change: 1 addition & 0 deletions
1
test/fixtures/coordinate-transformation/exemplar/expected_analysis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
1 change: 1 addition & 0 deletions
1
test/fixtures/elyses-analytic-enchantments/exemplar/expected_analysis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
1 change: 1 addition & 0 deletions
1
test/fixtures/elyses-destructured-enchantments/exemplar/expected_analysis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
1 change: 1 addition & 0 deletions
1
test/fixtures/elyses-enchantments/exemplar/expected_analysis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
1 change: 1 addition & 0 deletions
1
test/fixtures/elyses-looping-enchantments/exemplar/expected_analysis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
1 change: 1 addition & 0 deletions
1
test/fixtures/elyses-transformative-enchantments/exemplar/expected_analysis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
1 change: 1 addition & 0 deletions
1
test/fixtures/poetry-club-door-policy/exemplar/expected_analysis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
1 change: 1 addition & 0 deletions
1
test/fixtures/translation-service/exemplar/expected_analysis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.general.exemplar","type":"celebratory"}]} |
1 change: 1 addition & 0 deletions
1
test/fixtures/vehicle-purchase/uses-if-else/expected_analysis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.vehicle-purchase.use_if_else","params":{"function":"chooseVehicle"},"type":"informative"},{"comment":"javascript.vehicle-purchase.use_if_else","params":{"function":"calculateResellPrice"},"type":"informative"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"javascript.vehicle-purchase.unnecessary_if_statement","type":"actionable"}]} |