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

Fix issue 393 (x:call-scenarios template references 'this' element) #562

Merged
merged 1,298 commits into from
Jul 29, 2019

Conversation

AirQuick
Copy link
Member

This pull request derives from #561. So needs to be handled after that.


Fixes #393

Looking back the change history, the following changes are worth noting:

  1. The responsibility of setting the default value of the $pending tunnel parameter was distributed to the x:call-scenarios template and the x:compile-scenarios template: 82c8d10

  2. The default $pending value in the x:call-scenarios template was mis-edited while rewriting: 36da391

  3. The default $pending value was updated only in the x:compile-scenarios template: 3366f94

This pull request fixes the mis-edit (happened in 36da391) and follows the update (happened in 3366f94).

I can't provide a specific test for this fix, because the default $pending value in the x:call-scenarios template does not seem to take effect in the current code path. It may take effect in the future, so I propose this fix now.

The overall tests are in xspec-focus-1.xspec, xspec-focus-2.xspec and xspec-pending.xspec and slightly improved by #561.

# Conflicts:
#	src/compiler/generate-common-tests.xsl
#	src/compiler/generate-xspec-tests.xsl
#	test/generate-xspec-tests.xspec
# Conflicts:
#	.travis.yml
#	appveyor.yml
# Conflicts:
#	.travis.yml
#	appveyor.yml
# Conflicts:
#	test/end-to-end/cases/expected/query/xspec-153-result.html
# Conflicts:
#	test/generate-tests-utils.xspec
# Conflicts:
#	test/end-to-end/cases/expected/query/xspec-67-result.html
#	test/end-to-end/cases/expected/query/xspec-three-dots-result.html
#	test/end-to-end/cases/xspec-67.xspec
#	test/end-to-end/cases/xspec-three-dots.xspec
#	test/generate-tests-utils.xspec
#	test/generate-x-utils.xspec
# Conflicts:
#	test/generate-tests-utils.xspec
# Conflicts:
#	test/win-bats/collection.xml
#	test/xspec.bats
# Conflicts:
#	test/end-to-end/cases/expected/query/xspec-three-dots-result.html
…01-22

# Conflicts:
#	.travis.yml
#	appveyor.yml
# Conflicts:
#	src/reporter/format-xspec-report.xsl
#	test/end-to-end/cases/expected/stylesheet/xspec-serialize-result.html
#	test/end-to-end/cases/expected/stylesheet/xspec-three-dots-result.html
@AirQuick AirQuick requested a review from galtm July 6, 2019 01:02
@AirQuick
Copy link
Member Author

AirQuick commented Jul 6, 2019

@galtm
I still do not fully understand how pending and focus work. So I thought I'd better ask your review.

@galtm
Copy link
Member

galtm commented Jul 8, 2019

your review

I'll try to review it this week.

@@ -168,7 +188,7 @@
corresponding call instruction at some point).
-->
<xsl:template name="x:call-scenarios">
<xsl:param name="pending" select="this//@focus" tunnel="yes" as="node()?"/>
<xsl:param name="pending" select="(.//@focus)[1]" tunnel="yes" as="node()?"/>
Copy link
Member

Choose a reason for hiding this comment

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

Here is what I think I'm seeing in the XSLT case. I haven't looked at the XQuery case as much.

When the name="x:call-scenarios" template operates on x:description, the default value is assigned to the $pending tunnel parameter. However, the value does not matter because the generated name="t:main" template needs to call the generated templates corresponding to all the top-level scenarios, whether they are pending or not. (Pending status affects deeper-level parts of the generated code.)

When the name="x:call-scenarios" template operates on x:scenario, the default value of the $pending tunnel parameter does not get assigned because a value came from the calling name="x:output-scenario" template. Before that, the $pending value came from the calling match="x:scenario" mode="x:compile" template's $new-pending variable, which reflects whether the scenario being operated on should be treated as pending.

Please correct anything that sounds inaccurate. I want to understand the compiler code and it's complicated.

I agree with you that the default does not matter in the current code path. As for possible future changes, I'm not sure whether select="(.//@focus)[1]" or select="()" is more suitable; maybe whoever makes the future changes will need to think through the initialization and propagation of $pending based on what those changes are trying to do. I do think that what you have makes more sense than a reference to a this element that does not exist.

Is there value in adding a comment like, "Default value of pending does not affect compiler output but is here if needed in the future"? That could save someone time trying to figure out what you now know. If you think it's extraneous, it's fine not to add it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the invaluable review. Adding a comment is a very nice idea! I added it to this pull request: a98f70d

Copy link
Member

Choose a reason for hiding this comment

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

You're very welcome! Thanks for adding the comment.

# Conflicts:
#	test/end-to-end/cases/expected/query/xspec-report-junit.xml
#	test/end-to-end/cases/expected/query/xspec-report-result.html
#	test/end-to-end/cases/expected/query/xspec-report-result.xml
#	test/end-to-end/cases/expected/stylesheet/xspec-report-junit.xml
#	test/end-to-end/cases/expected/stylesheet/xspec-report-result.html
#	test/end-to-end/cases/expected/stylesheet/xspec-report-result.xml
#	test/end-to-end/cases/xspec-report.xspec
@AirQuick AirQuick merged commit e38f5e5 into xspec:master Jul 29, 2019
@AirQuick AirQuick deleted the fix_issue-393 branch July 29, 2019 12:21
@AirQuick
Copy link
Member Author

@cirulls
Merged this bug fix.

Thanks @galtm for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x:call-scenarios template references this//@focus
2 participants