Skip to content
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

Added import test to fix import for parse_rc #97

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

icnocop
Copy link
Contributor

@icnocop icnocop commented Nov 18, 2018

Fixes #92

@codecov-io
Copy link

codecov-io commented Nov 18, 2018

Codecov Report

Merging #97 into master will increase coverage by 1.04%.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #97      +/-   ##
==========================================
+ Coverage   52.05%   53.09%   +1.04%     
==========================================
  Files          91       91              
  Lines        6901     6904       +3     
  Branches     1730     1731       +1     
==========================================
+ Hits         3592     3666      +74     
+ Misses       2645     2561      -84     
- Partials      664      677      +13
Impacted Files Coverage Δ
lib/Serge/Importer.pm 42.85% <100%> (+40.37%) ⬆️
lib/Serge/Engine/Plugin/parse_rc.pm 78.33% <50%> (+2.89%) ⬆️
lib/Serge/Engine.pm 60.73% <0%> (ø) ⬆️
lib/Serge/Engine/Job.pm 87.87% <0%> (+1.01%) ⬆️
lib/Serge/Plugin/Base.pm 86.36% <0%> (+4.54%) ⬆️
lib/Serge/Interface/PluginHost.pm 94.44% <0%> (+16.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa5ac6b...eb7a379. Read the comment docs.

@@ -86,7 +86,7 @@ sub parse {
if ($orig_str) {
my $str = $orig_str;
$str =~ s/""/"/g;
$translated_str = &$callbackref($str, undef, $hint, undef, $lang);
$translated_str = &$callbackref($str, undef, $hint, undef, $lang, $hint);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a proper fix. The last parameter is supposed to be a unique key (if available in the file), whereas you just use hint as a key there (which can be constructed in the parser in multiple ways).

I suggest moving this change out of the importer test PR.

t/engine.t Outdated
@@ -9,7 +9,7 @@ use strict;
# script or assign them to the environment variable SERGE_ENGINE_TESTS as a
# comma-separated list. The following two examples are equivalent:
#
# perl t/enigne.t parse_json parse_strings
# perl t/engine.t parse_json parse_strings
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you externalize all typos / var name refactoring in a smaller PR that we can merge separately and which won't distract from the main importer PR?

t/engine.t Outdated
@@ -42,7 +42,8 @@ sub Serge::Engine::file_mtime {
return 12345678;
}

my $thisdir = dirname(abs_path(__FILE__));
my $this_dir = dirname(abs_path(__FILE__));
my $tests_dir = catfile($this_dir, 'data', 'engine');
Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment above for var name refactoring.

@icnocop icnocop force-pushed the import_parser_rc branch 2 times, most recently from 69caeba to dbd2f39 Compare December 21, 2018 04:12
@icnocop
Copy link
Contributor Author

icnocop commented Dec 21, 2018

I've updated the PR with your code comments and added #98 for the typo and refactoring as suggested.

Thank you.

@icnocop icnocop force-pushed the import_parser_rc branch 2 times, most recently from 8ea2de9 to 01fe5ad Compare December 21, 2018 05:01
@icnocop
Copy link
Contributor Author

icnocop commented Dec 21, 2018

When I took out passing $hint as the last parameter to $callbackref, the test fails with the error:

Parser plugin didn't provide a key value in a callback. Importing translations with this plugin is not possible, unless you use `--disambiguate-keys` option.

Is that expected given the input file application.rc?

If so, can you explain why, please?

All the keys in the STRINGTABLE are unique, so I don't expect any disambiguity.

When I pass $idstr as the last parameter to $callbackref, the test fails with errors like:

Duplicate key 'BEGIN' found in source file

@@ -86,7 +86,7 @@ sub parse {
if ($orig_str) {
my $str = $orig_str;
$str =~ s/""/"/g;
$translated_str = &$callbackref($str, undef, $hint, undef, $lang);
$translated_str = &$callbackref($str, undef, $hint, undef, $lang, $idstr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Now, this is a proper fix, and I'll be happy to merge the PR with this single-line change.

As for the importer, right now it is just a copy-paste of t/engine.t, and requires writing some additional tests; it also doesn't seem to do the actual import as the reference translations table in your test is empty. Would be more interesting to somehow hook the importing mode right into engine.t, where it would first generate the translations (and check them against reference files, and then use importer to import translations back and see that the reference import database matches the generated one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created PR #99 with just this single-line change.

Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @iafan.

I updated the PR with another commit to fix more issues with import and parse_rc.
The translations table in the reference output are now populated correctly.

I agree that we should try to re-use some of the code in engine.t to consolidate the duplicate code this PR creates.
I'm not sure how to implement it as you suggested yet, but I'll try to at least get one step closer.

I'm wondering if you want me to create a new PR with just the changes in Importer.pm and parse_rc.pm?

Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In regards to "use importer to import translations back and see that the reference import database matches the generated one.", do you expect there to be a new reference-output database to check against the import? For example, .\t\data\engine\parse_rc\00\reference-output\imported-database? The properties and translations tables seem to be the only ones that are different.

@icnocop icnocop force-pushed the import_parser_rc branch from 01fe5ad to 5831284 Compare March 8, 2019 02:46
Fixed parsing rc file and import test
@icnocop icnocop force-pushed the import_parser_rc branch from 2b70f1e to b260bde Compare March 8, 2019 11:56
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.

serge import with parse_rc returns ERROR: Parser plugin didn't provide a key value in a callback.
3 participants