Skip to content

Commit 4b64a6e

Browse files
committed
✅ Update smoke tests with generic-representer
- Add test on expected_representation.json - Remove smoke tests that expect errors (not supported anymore)
1 parent c6b5ca4 commit 4b64a6e

File tree

20 files changed

+13
-91
lines changed

20 files changed

+13
-91
lines changed

bin/run-tests.sh

+5-26
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,17 @@ exit_code=0
1717
for test_dir in tests/*; do
1818
test_dir_name=$(basename "${test_dir}")
1919
test_dir_path=$(realpath "${test_dir}")
20-
representation_file_path="${test_dir_path}/representation.txt"
21-
expected_representation_file_path="${test_dir_path}/expected_representation.txt"
22-
mapping_file_path="${test_dir_path}/mapping.json"
23-
expected_mapping_file_path="${test_dir_path}/expected_mapping.json"
24-
expected_error_file_path="${test_dir_path}/expected_representation.txt"
25-
expect_error="${test_dir_path}/.expect-error"
2620

2721
bin/run.sh "${test_dir_name}" "${test_dir_path}" "${test_dir_path}"
28-
test_exit_code=$?
2922

30-
if [[ -f "${expect_error}" ]]; then
31-
if [[ $test_exit_code -eq 0 ]]; then
32-
echo 'Expected non-zero exit code'
33-
exit_code=1
34-
fi
35-
else
36-
echo "${test_dir_name}: comparing representation.txt to expected_representation.txt"
37-
diff "${representation_file_path}" "${expected_representation_file_path}"
38-
39-
if [ $? -ne 0 ]; then
40-
echo "FAILED"
41-
exit_code=1
42-
fi
43-
44-
echo "${test_dir_name}: comparing mapping.json to expected_mapping.json"
45-
diff "${mapping_file_path}" "${expected_mapping_file_path}"
23+
for file in representation.txt representation.json mapping.json; do
24+
expected_file="expected_${file}"
25+
echo "${test_dir_name}: comparing ${file} to ${expected_file}"
4626

47-
if [ $? -ne 0 ]; then
48-
echo "FAILED"
27+
if ! diff "${test_dir_path}/${file}" "${test_dir_path}/${expected_file}"; then
4928
exit_code=1
5029
fi
51-
fi
30+
done
5231
done
5332

5433
exit ${exit_code}

bin/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ mkdir -p "${output_dir}"
3333

3434
echo "${slug}: creating representation..."
3535

36+
# Create the representation for the solution
3637
/usr/local/bin/php /opt/representer/main.php "$@"

src/DirectoryRepresenter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function represent(): Result
6262

6363
return new Result(
6464
$filesRepresentation,
65-
'{"version":2}',
65+
'{"version": 2}',
6666
$mapping->toJson(),
6767
);
6868
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version": 2}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version": 2}

tests/example-multiple-files-missing/.expect-error

-1
This file was deleted.

tests/example-multiple-files-missing/.meta/config.json

-5
This file was deleted.

tests/example-multiple-files-missing/LeapTests.php

-10
This file was deleted.

tests/example-multiple-files-missing/Tools.php

-9
This file was deleted.

tests/example-multiple-files-partially-missing/.expect-error

-1
This file was deleted.

tests/example-multiple-files-partially-missing/.meta/config.json

-5
This file was deleted.

tests/example-multiple-files-partially-missing/Leap.php

-11
This file was deleted.

tests/example-multiple-files-partially-missing/Tools.php

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version": 2}

tests/example-single-file-missing/.expect-error

-1
This file was deleted.

tests/example-single-file-missing/.meta/config.json

-5
This file was deleted.

tests/example-single-file-missing/LeapTests.php

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version": 2}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version": 2}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version": 2}

0 commit comments

Comments
 (0)