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

testsuite failure on i386 after applying test fix from master #60

Closed
LocutusOfBorg opened this issue Jun 24, 2017 · 16 comments
Closed

testsuite failure on i386 after applying test fix from master #60

LocutusOfBorg opened this issue Jun 24, 2017 · 16 comments

Comments

@LocutusOfBorg
Copy link

LocutusOfBorg commented Jun 24, 2017

Hello, as said, I updated libyaml with the fix for the testsuite failures (e.g. haskell-yaml), in particular this single commit
56400d9

the problem is that now pyyaml has some test failing on i386
original yaml (latest version)
https://launchpadlibrarian.net/325264273/buildlog_ubuntu-artful-i386.pyyaml_3.12-1build2_BUILDING.txt.gz
patched yaml (commit 56400d9)

https://launchpadlibrarian.net/325269141/buildlog_ubuntu-artful-i386.pyyaml_3.12-1build2_BUILDING.txt.gz

set -e && for i in 2.7; do \
  echo "-- running tests for "$i" plain --" ; \
  python$i -c "import sys ; sys.path.insert(0, 'debian/python-yaml/usr/lib/python$i/dist-packages/'); \
      sys.path.insert(0, 'tests/lib'); import test_all; test_all.main([])";\
done
-- running tests for 2.7 plain --
..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................FF..F.....F....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
===========================================================================
test_emitter_styles_ext(tests/data/spec-07-09.data, tests/data/spec-07-09.canonical): FAILURE
Traceback (most recent call last):
  File "tests/lib/test_appliance.py", line 65, in execute
    function(verbose=verbose, *filenames)
  File "tests/lib/test_yaml_ext.py", line 240, in wrapper
    function(*args, **kwds)
  File "tests/lib/test_emitter.py", line 62, in test_emitter_styles
    _compare_events(events, new_events)
  File "tests/lib/test_emitter.py", line 15, in _compare_events
    assert event1.value == event2.value, (event1, event2)
AssertionError: see below
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(ScalarEvent(anchor=None, tag=u'tag:yaml.org,2002:str', implicit=(False, False), value=u'foo'),
 ScalarEvent(anchor=None, tag=u'tag:yaml.org,2002:str', implicit=(False, False), value=u'foo %YAML 1.1'))
---------------------------------------------------------------------------
tests/data/spec-07-09.data:
---
foo
...
# Repeated end marker.
...
---
bar
# No end marker.
---
baz
...
---------------------------------------------------------------------------
tests/data/spec-07-09.canonical:
%YAML 1.1
---
!!str "foo"
%YAML 1.1
---
!!str "bar"
%YAML 1.1
---
!!str "baz"
===========================================================================
test_emitter_styles_ext(tests/data/spec-07-10.data, tests/data/spec-07-10.canonical): FAILURE
Traceback (most recent call last):
  File "tests/lib/test_appliance.py", line 65, in execute
    function(verbose=verbose, *filenames)
  File "tests/lib/test_yaml_ext.py", line 240, in wrapper
    function(*args, **kwds)
  File "tests/lib/test_emitter.py", line 62, in test_emitter_styles
    _compare_events(events, new_events)
  File "tests/lib/test_emitter.py", line 15, in _compare_events
    assert event1.value == event2.value, (event1, event2)
AssertionError: see below
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(ScalarEvent(anchor=None, tag=u'tag:yaml.org,2002:str', implicit=(False, False), value=u'Root flow scalar'),
 ScalarEvent(anchor=None, tag=u'tag:yaml.org,2002:str', implicit=(False, False), value=u'Root flow scalar %YAML 1.1'))
---------------------------------------------------------------------------
tests/data/spec-07-10.data:
"Root flow
 scalar"
--- !!str >
 Root block
 scalar
---
# Root collection:
foo : bar
... # Is optional.
---
# Explicit document may be empty.
---------------------------------------------------------------------------
tests/data/spec-07-10.canonical:
%YAML 1.1
---
!!str "Root flow scalar"
%YAML 1.1
---
!!str "Root block scalar\n"
%YAML 1.1
---
!!map {
  ? !!str "foo"
  : !!str "bar"
}
---
#!!str ""
!!null ""
===========================================================================
test_emitter_styles_ext(tests/data/spec-07-13.data, tests/data/spec-07-13.canonical): FAILURE
Traceback (most recent call last):
  File "tests/lib/test_appliance.py", line 65, in execute
    function(verbose=verbose, *filenames)
  File "tests/lib/test_yaml_ext.py", line 240, in wrapper
    function(*args, **kwds)
  File "tests/lib/test_emitter.py", line 62, in test_emitter_styles
    _compare_events(events, new_events)
  File "tests/lib/test_emitter.py", line 15, in _compare_events
    assert event1.value == event2.value, (event1, event2)
AssertionError: see below
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(ScalarEvent(anchor=None, tag=u'!foo', implicit=(False, False), value=u'No directives'),
 ScalarEvent(anchor=None, tag=u'!foo', implicit=(False, False), value=u'No directives %TAG ! %21foo'))
---------------------------------------------------------------------------
tests/data/spec-07-13.data:
! "First document"
---
!foo "No directives"
%TAG ! !foo
---
!bar "With directives"
%YAML 1.1
---
!baz "Reset settings"
---------------------------------------------------------------------------
tests/data/spec-07-13.canonical:
%YAML 1.1
---
!!str "First document"
---
!<!foo> "No directives"
---
!<!foobar> "With directives"
---
!<!baz> "Reset settings"
===========================================================================
test_emitter_styles_ext(tests/data/spec-08-08.data, tests/data/spec-08-08.canonical): FAILURE
Traceback (most recent call last):
  File "tests/lib/test_appliance.py", line 65, in execute
    function(verbose=verbose, *filenames)
  File "tests/lib/test_yaml_ext.py", line 240, in wrapper
    function(*args, **kwds)
  File "tests/lib/test_emitter.py", line 62, in test_emitter_styles
    _compare_events(events, new_events)
  File "tests/lib/test_emitter.py", line 15, in _compare_events
    assert event1.value == event2.value, (event1, event2)
AssertionError: see below
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(ScalarEvent(anchor=None, tag=u'tag:yaml.org,2002:str', implicit=(False, False), value=u'foo bar'),
 ScalarEvent(anchor=None, tag=u'tag:yaml.org,2002:str', implicit=(False, False), value=u'foo bar %YAML 1.1'))
---------------------------------------------------------------------------
tests/data/spec-08-08.data:
---
foo:
 "bar
 baz"
---
"foo
 bar"
---
foo
 bar
--- |
 foo
...
---------------------------------------------------------------------------
tests/data/spec-08-08.canonical:
%YAML 1.1
---
!!map {
  ? !!str "foo"
  : !!str "bar baz"
}
%YAML 1.1
---
!!str "foo bar"
%YAML 1.1
---
!!str "foo bar"
%YAML 1.1
---
!!str "foo\n"
===========================================================================
TESTS: 2573
FAILURES: 4
set -e && for i in 2.7; do \
  echo "-- running tests for "$i" debug --" ; \
  python$i-dbg -c "import sys ; sys.path.insert(0, 'debian/python-yaml-dbg/usr/lib/python$i/dist-packages/'); \
      sys.path.insert(0, 'tests/lib'); import test_all; test_all.main([])";\
done
-- running tests for 2.7 debug --
..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................FF..F.....F....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

can you please help?

thanks a lot
(the same failure happens with the latest git master FWIW)

@jrtc27
Copy link

jrtc27 commented Jun 29, 2017

So the problem here is when emitting two documents back to back with the plain style, where one document is "foo" and the other is "bar". In the double-quoted style, this becomes:

%YAML 1.1
--- !!str "foo"
%YAML 1.1
--- !!str "bar"

However, in the plain style, this is emitted as:

%YAML 1.1
--- !!str foo
%YAML 1.1
--- !!str bar

This is now incorrect, as the plain style allows continuation lines, so the second %YAML 1.1 should be parsed as part of the string foo, giving !!str "foo %YAML 1.1". This used to be fine, because open_ended was set, so an explicit terminator was added, giving:

%YAML 1.1
--- !!str foo
...
%YAML 1.1
--- !!str bar
...

Therefore, I believe that the commit should be reverted, as it was serving a purpose. Technically the final terminator in the stream is not needed, but it allows streams to be concatenated without having to worry, so I guess it's fine (though if you dropped it, I imagine that would also fix the tests in consumers of the library, as they probably aren't expecting the final one; this is certainly the case with haskell-yaml).

@jrtc27
Copy link

jrtc27 commented Jun 29, 2017

Indeed, with the following patches, pyyaml's test suite passes again, but the final unnecessary trailing terminator is not emitted.

From 7c2e6f47e1b12ca3dfa9ea2f6c65e9bd8a02e8c8 Mon Sep 17 00:00:00 2001
From: James Clarke <[email protected]>
Date: Thu, 29 Jun 2017 02:24:53 +0100
Subject: [PATCH 1/2] Revert "This code is not needed and breaks tests"

This reverts commit 56400d976a1999156b1abfd674c3122843980260.
---
 src/emitter.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/emitter.c b/src/emitter.c
index a5b7ff8..c593a7d 100644
--- a/src/emitter.c
+++ b/src/emitter.c
@@ -1946,6 +1946,10 @@ yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
 
     emitter->whitespace = 0;
     emitter->indention = 0;
+    if (emitter->root_context)
+    {
+        emitter->open_ended = 1;
+    }
 
     return 1;
 }
-- 
2.13.2


From e5ebb70a01cc0fbd9e519050d51d704f58c2a33d Mon Sep 17 00:00:00 2001
From: James Clarke <[email protected]>
Date: Thu, 29 Jun 2017 02:26:09 +0100
Subject: [PATCH 2/2] Skip trailing document terminator at the end of the
 stream

---
 src/emitter.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/src/emitter.c b/src/emitter.c
index c593a7d..1502590 100644
--- a/src/emitter.c
+++ b/src/emitter.c
@@ -649,14 +649,6 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
 
     else if (event->type == YAML_STREAM_END_EVENT)
     {
-        if (emitter->open_ended)
-        {
-            if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
-                return 0;
-            if (!yaml_emitter_write_indent(emitter))
-                return 0;
-        }
-
         if (!yaml_emitter_flush(emitter))
             return 0;
 
-- 
2.13.2

@LocutusOfBorg
Copy link
Author

ping

@LocutusOfBorg
Copy link
Author

@ingydotnet do you have any advice for this patch?

@jrtc27
Copy link

jrtc27 commented Aug 15, 2017

Ping

@ingydotnet
Copy link
Member

I will add this patch as a candidate to the upcoming 0.1.8 release. https://github.com/yaml/libyaml/projects/1

@LocutusOfBorg
Copy link
Author

@ingydotnet I think there has been a mistake in this patch apply...

I see the latest libyaml included the first version of my patch, but the one from @jrtc27 is a better version... can you please revert and apply this one? #60 (comment)

@LocutusOfBorg
Copy link
Author

or maybe you have your reasons for this? 56400d9#diff-55aa019b48be9270c41a41aad1bd405c
the commit message seems to indicate this has been not a mistake...

@andersk
Copy link

andersk commented Jun 27, 2018

I’m not sure this should be closed. PyYAML 4.1 still fails its test suite with LibYAML 0.2.1 as described in the original report.

@LocutusOfBorg
Copy link
Author

reopened!

@straight-shoota
Copy link

This has come up as an issue with the libyaml-based YAML builder for Crystal in crystal-lang/crystal#6283
The change to remove document end marker was certainly good. And it probably doesn't have a huge negative impact as YAML documents consisting of only a single scalar are not very common outside of YAML test suites. But it is still a breaking change and I'd suggest to mention this in the release announcement to make it easier to discover.

perlpunk added a commit that referenced this issue Jun 29, 2018
See also issue #60

Revert "This code is not needed and breaks tests"

This reverts commit 56400d9.
@perlpunk
Copy link
Member

I created #122 to revert the commit

@perlpunk
Copy link
Member

I explained in my PR why this needs to be reverted. libyaml is creating invalid YAML in some cases.

@perlpunk
Copy link
Member

@jrtc27 I'll have a look at your patches, thanks

perlpunk added a commit that referenced this issue Jun 29, 2018
(only when explicitly requested)

@jrtc2++ for the patch.

See #60
@perlpunk
Copy link
Member

I added the patch from @jrtc27 to #122, looks good!

perlpunk added a commit that referenced this issue Jun 29, 2018
(only when explicitly requested)

@jrtc27++ for the patch.

See #60
@perlpunk
Copy link
Member

perlpunk commented Jun 7, 2019

The fixes have been released, so I'm closing this.
Commits: 56400d9, 8ee83c0, 56f4b17

@perlpunk perlpunk closed this as completed Jun 7, 2019
perlpunk added a commit that referenced this issue Dec 26, 2019
In YAML 1.1, the document end marker `...` is optional even if the next document starts with a directive:
https://github.com/yaml/pyyaml/blob/master/tests/data/spec-07-09.canonical
```
%YAML 1.1
---
!!str "foo"
%YAML 1.1
---
!!str "bar"
%YAML 1.1
---
!!str "baz"
```
It is only required if the scalar is "open ended", for example for plain scalars.

In YAML 1.2 the `...` marker is always required before a directive.

My suggestion would be to make the output 1.2 compatible. It will still be 1.1 compatible, so that shouldn't be a problem.

I believe this will also make it easier to fix #123 which was introduced with the last fixes regarding `open_ended`. I think I can make a fix for this soon after this issue is fixed.
Fixing #123 without this would be a bit more complicated.

If we do this, we also need to adjust PyYAML to behave the same.

Related issues/commits:
- #60
- #122
- 56400d9, 8ee83c0, 56f4b17
perlpunk added a commit that referenced this issue Mar 23, 2020
In YAML 1.1, the document end marker `...` is optional even if the next document starts with a directive:
https://github.com/yaml/pyyaml/blob/master/tests/data/spec-07-09.canonical
```
%YAML 1.1
---
!!str "foo"
%YAML 1.1
---
!!str "bar"
%YAML 1.1
---
!!str "baz"
```
It is only required if the scalar is "open ended", for example for plain scalars.

In YAML 1.2 the `...` marker is always required before a directive.

My suggestion would be to make the output 1.2 compatible. It will still be 1.1 compatible, so that shouldn't be a problem.

I believe this will also make it easier to fix #123 which was introduced with the last fixes regarding `open_ended`. I think I can make a fix for this soon after this issue is fixed.
Fixing #123 without this would be a bit more complicated.

If we do this, we also need to adjust PyYAML to behave the same.

Related issues/commits:
- #60
- #122
- 56400d9, 8ee83c0, 56f4b17
perlpunk added a commit that referenced this issue Mar 26, 2020
In YAML 1.1, the document end marker `...` is optional even if the next document starts with a directive:
https://github.com/yaml/pyyaml/blob/master/tests/data/spec-07-09.canonical
```
%YAML 1.1
---
!!str "foo"
%YAML 1.1
---
!!str "bar"
%YAML 1.1
---
!!str "baz"
```
It is only required if the scalar is "open ended", for example for plain scalars.

In YAML 1.2 the `...` marker is always required before a directive.

My suggestion would be to make the output 1.2 compatible. It will still be 1.1 compatible, so that shouldn't be a problem.

I believe this will also make it easier to fix #123 which was introduced with the last fixes regarding `open_ended`. I think I can make a fix for this soon after this issue is fixed.
Fixing #123 without this would be a bit more complicated.

If we do this, we also need to adjust PyYAML to behave the same.

Related issues/commits:
- #60
- #122
- 56400d9, 8ee83c0, 56f4b17
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

No branches or pull requests

6 participants