-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
256 additions
and
5 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
tests/tmp/ |
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,26 @@ | ||
# Contributions guide | ||
|
||
You only need Inkscape>=1.0, [xvfb][xvfb-package] and a posix shell to develop | ||
and test. | ||
|
||
## Make changes to the code | ||
|
||
1. Move [text_braille_l18n.inx][ext-inx] and [text_braille_l18n.py][ext-py] | ||
files to your user's extensions directory. If you don't know its location, | ||
open it from `Edit` -> `Preferences` -> `System` -> `Users extensions`. | ||
1. Edit the code there. | ||
1. Once edited and manually tested, move the files to this repository, it's | ||
time to run tests. | ||
|
||
## Test your changes | ||
|
||
- `sh tests/run.sh`: Run tests. | ||
- `DEBUG=1 sh tests/run.sh`: Run tests showing all executed commands (mainly | ||
for tests script debugging). | ||
|
||
You'll see that a folder is created under `tests/tmp/` where the output for | ||
every locale is stored. | ||
|
||
[xvfb]: https://packages.debian.org/es/sid/xvfb | ||
[ext-inx]: https://github.com/mondeja/inkscape-braille-l18n-ext/blob/master/text_braille_l18n.inx | ||
[ext-py]: https://github.com/mondeja/inkscape-braille-l18n-ext/blob/master/text_braille_l18n.py |
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,6 @@ | ||
⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵ | ||
⠨⠁⠨⠃⠨⠉⠨⠙⠨⠑⠨⠋⠨⠛⠨⠓⠨⠊⠨⠚⠨⠅⠨⠇⠨⠍⠨⠝⠨⠕⠨⠏⠨⠟⠨⠗⠨⠎⠨⠞⠨⠥⠨⠧⠨⠺⠨⠭⠨⠽⠨⠵ | ||
⠀⠐⠄'⠐⠠⠂⠦^⠨⠂⠂⠔⠐⠅⠤⠄⠸⠴[⠸⠎⠖⠖⠯⠆⠒⠣_⠢]#⠜⠶⠖⠲ | ||
⠼⠚⠼⠁⠼⠃⠼⠉⠼⠙⠼⠑⠼⠋⠼⠛⠼⠓⠼⠊ | ||
á⠿⠌⠪⠾⠷⠮ì⠬ùäë⠻ö⠳Á⠨⠿⠨⠌⠨⠪⠨⠾⠨⠷⠨⠮Ì⠨⠬ÙÄË⠨⠻Ö⠨⠳ | ||
⠯⠨⠯⠸⠴⠸⠴⠴⠣⠨⠉⠜⠣⠨⠗⠜⠣⠨⠏⠜⠣⠨⠇⠜⠠⠂⠐⠄⠐⠅⠨⠂⠸⠇⠐⠇⠸⠂⠤⠤⠸⠑⠸⠎⠘⠉⠐⠮⠸⠽⠸⠽ |
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,6 @@ | ||
⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵ | ||
⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵ | ||
⠀⠳⠄⠈⠌⠐⠘⠜⠠⠡⠣⠤⠨⠩⠪⠫⠬⠮⠯⠰⠱⠷⠸⠹⠻⠼⠾⠿⠬÷ | ||
⠴⠂⠆⠒⠲⠢⠖⠶⠦⠔ | ||
áéíóúàèìòùäëïöüÁÉÍÓÚÀÈÌÒÙÄËÏÖÜ | ||
çÇ⠩‰©®℗🄯⠌⠳⠣⠜|{}—€⠫¢£¥¥ |
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,6 @@ | ||
⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵ | ||
⠨⠁⠨⠃⠨⠉⠨⠙⠨⠑⠨⠋⠨⠛⠨⠓⠨⠊⠨⠚⠨⠅⠨⠇⠨⠍⠨⠝⠨⠕⠨⠏⠨⠟⠨⠗⠨⠎⠨⠞⠨⠥⠨⠧⠨⠺⠨⠭⠨⠽⠨⠵ | ||
⠀⠐⠄'⠐⠠⠂⠦^⠨⠂⠂⠔⠐⠅⠤⠄⠸⠴[⠸⠎⠖⠖⠯⠆⠒⠣_⠢]#⠜⠶⠖⠲ | ||
⠼⠚⠼⠁⠼⠃⠼⠉⠼⠙⠼⠑⠼⠋⠼⠛⠼⠓⠼⠊ | ||
⠷⠮⠌⠬⠾àèìòùäëïö⠳⠨⠷⠨⠮⠨⠌⠨⠬⠨⠾ÀÈÌÒÙÄËÏÖ⠨⠳ | ||
çÇ⠸⠴⠸⠴⠴⠣⠨⠉⠜⠣⠨⠗⠜⠣⠨⠏⠜⠣⠨⠇⠜⠠⠂⠐⠄⠐⠅⠨⠂⠸⠇⠐⠇⠸⠂⠤⠤⠸⠑⠸⠎⠘⠉⠐⠮⠸⠽⠸⠽ |
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,6 @@ | ||
⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵ | ||
⠨⠁⠨⠃⠨⠉⠨⠙⠨⠑⠨⠋⠨⠛⠨⠓⠨⠊⠨⠚⠨⠅⠨⠇⠨⠍⠨⠝⠨⠕⠨⠏⠨⠟⠨⠗⠨⠎⠨⠞⠨⠥⠨⠧⠨⠺⠨⠭⠨⠽⠨⠵ | ||
⠀⠐⠄'⠐⠠⠂⠦^⠨⠂⠂⠔⠐⠅⠤⠄⠸⠴[⠸⠎⠖⠖⠯⠆⠒⠣_⠢]#⠜⠶⠖⠲ | ||
⠼⠚⠼⠁⠼⠃⠼⠉⠼⠙⠼⠑⠼⠋⠼⠛⠼⠓⠼⠊ | ||
⠷⠮⠌⠬⠾àèìòùäëïö⠳⠨⠷⠨⠮⠨⠌⠨⠬⠨⠾ÀÈÌÒÙÄËÏÖ⠨⠳ | ||
çÇ⠸⠴⠸⠴⠴⠣⠨⠉⠜⠣⠨⠗⠜⠣⠨⠏⠜⠣⠨⠇⠜⠠⠂⠐⠄⠐⠅⠨⠂⠸⠇⠐⠇⠸⠂⠤⠤⠸⠑⠸⠎⠘⠉⠐⠮⠸⠽⠸⠽ |
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,6 @@ | ||
⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵ | ||
⠨⠁⠨⠃⠨⠉⠨⠙⠨⠑⠨⠋⠨⠛⠨⠓⠨⠊⠨⠚⠨⠅⠨⠇⠨⠍⠨⠝⠨⠕⠨⠏⠨⠟⠨⠗⠨⠎⠨⠞⠨⠥⠨⠧⠨⠺⠨⠭⠨⠽⠨⠵ | ||
⠀⠐⠄'⠐⠠⠂⠦^⠨⠂⠂⠔⠐⠅⠤⠄⠸⠴[⠸⠎⠖⠖⠯⠆⠒⠣_⠢]#⠜⠶⠖⠲ | ||
⠼⠚⠼⠁⠼⠃⠼⠉⠼⠙⠼⠑⠼⠋⠼⠛⠼⠓⠼⠊ | ||
⠷⠮⠌⠬⠾àèìòùäëïö⠳⠨⠷⠨⠮⠨⠌⠨⠬⠨⠾ÀÈÌÒÙÄËÏÖ⠨⠳ | ||
çÇ⠸⠴⠸⠴⠴⠣⠨⠉⠜⠣⠨⠗⠜⠣⠨⠏⠜⠣⠨⠇⠜⠠⠂⠐⠄⠐⠅⠨⠂⠸⠇⠐⠇⠸⠂⠤⠤⠸⠑⠸⠎⠘⠉⠐⠮⠸⠽⠸⠽ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,141 @@ | ||
#!/bin/sh | ||
|
||
: ' | ||
Tests for braille-l18n Inkscape extension. You must have Inkscape installed | ||
in order to run this script. WARNING: if braille-l18n extension files are | ||
found inside your user extensions directory will be overwritten by the | ||
development files located in this directory! | ||
Environment variables: | ||
- DEBUG: If not empty, all executed commands will be shown in the output. | ||
' | ||
|
||
error() { | ||
printf "$1" >&2 | ||
} | ||
|
||
configure_script() { | ||
set -e | ||
if [ -n "$DEBUG" ]; then | ||
set -x | ||
fi | ||
|
||
if [ ! -f "text_braille_l18n.inx" ]; then | ||
error "You must be at the root of the directory to execute the tests.\n" | ||
exit 1 | ||
fi | ||
} | ||
|
||
prepare_tmp_folder() { | ||
rm -rf tests/tmp/ | ||
mkdir tests/tmp/ | ||
} | ||
|
||
print_user_extensions_directory() { | ||
printf "$(inkscape --user-data-directory)/extensions" | ||
} | ||
|
||
move_extension_to_user_extensions_directory() { | ||
extensions_directory="$(print_user_extensions_directory)" | ||
rm -f "$extensions_directory/text_braille_l18n.*" | ||
cp text_braille_l18n.* "$extensions_directory" | ||
} | ||
|
||
: ' | ||
Configure preferences.xml file so the extension braille-l18n can be | ||
configured to use the parameters specified for the test. | ||
$1 - Locale parameter. | ||
' | ||
configure_profile_preferences() { | ||
locale="$1" | ||
preferences_filepath="$(inkscape --user-data-directory)/preferences.xml" | ||
locale_pref="$(< $preferences_filepath grep -o "org.inkscape.text.braille-l18n.locale")" | ||
|
||
# if locale preference is present | ||
if [ -n "$locale_pref" ]; then | ||
# replace value with locale passed as function argument | ||
sed -i -r "s/org.inkscape.text.braille-l18n.locale=\"(.+)\"/org.inkscape.text.braille-l18n.locale=\"$locale\"/g" "$preferences_filepath" | ||
else | ||
# add extension preference after 'id="extensions"' line (extensions group) | ||
sed -i "s/id=\"extensions\"/&\n org.inkscape.text.braille-l18n.locale=\"$locale\"/g" "$preferences_filepath" | ||
fi; | ||
} | ||
|
||
get_locales() { | ||
echo "$(< "$PWD/text_braille_l18n.inx" grep '<option value=' | cut -d'"' -f2)" | ||
} | ||
|
||
: ' | ||
Extract Braille output from a produced SVG running a test using Inkscape, | ||
for further comparison. | ||
$1 - Path to the SVG file which Braille output will be extracted. | ||
' | ||
extract_svg_output_text() { | ||
< "$1" grep 'id="tspan' | cut -d'>' -f2 | ||
} | ||
|
||
test_extension_effect() { | ||
locale="$1" | ||
svg_output_filepath="$PWD/tests/tmp/$locale.out.svg" | ||
txt_output_filepath="tests/tmp/$locale.out.txt" | ||
txt_expect_filepath="tests/$locale.expect.txt" | ||
|
||
if [ ! -f "$txt_expect_filepath" ]; then | ||
error "File '$txt_expect_filepath' was expected to exist but not found!\nTests aborted.\n" | ||
exit 1 | ||
fi; | ||
|
||
printf "TEST: locale=$locale\n" | ||
|
||
# configure parameters for extension | ||
configure_profile_preferences "$locale" | ||
|
||
# run extension using inkscape in headless mode with Xvfb | ||
xvfb-run inkscape \ | ||
--batch-process \ | ||
--export-plain-svg \ | ||
--vacuum-defs \ | ||
--actions="select-by-element:text;org.inkscape.text.braille-l18n.noprefs;export-filename:$svg_output_filepath;export-do" \ | ||
tests/input.svg | ||
|
||
# extract braille output from produced SVG and save in other file | ||
extract_svg_output_text "$svg_output_filepath" > "$txt_output_filepath" | ||
|
||
if ! diff --brief "$txt_output_filepath" "$txt_expect_filepath"; then | ||
printf "Red: $txt_output_filepath - Green: $txt_expect_filepath\n" | ||
# ignore error (or file exits due to 'set -e') | ||
diff --color "$txt_output_filepath" "$txt_expect_filepath" || true | ||
printf "\n" | ||
printf "1" > "tests/tmp/exitcode" | ||
fi | ||
} | ||
|
||
run_tests() { | ||
# read possible locales from inx extension file | ||
get_locales | tr ' ' '\n' | while read locale; do | ||
test_extension_effect "$locale" | ||
done | ||
} | ||
|
||
cleanup_and_exit() { | ||
if [ -f "tests/tmp/exitcode" ]; then | ||
exitcode="$(cat tests/tmp/exitcode)" | ||
rm tests/tmp/exitcode | ||
else | ||
exitcode=1 | ||
fi | ||
exit $exitcode | ||
} | ||
|
||
main() { | ||
configure_script | ||
prepare_tmp_folder | ||
move_extension_to_user_extensions_directory | ||
run_tests | ||
cleanup_and_exit | ||
} | ||
|
||
main |
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