Skip to content

Tests are failing on Windows / Fix line ending handling #287

@jrfnl

Description

@jrfnl

All test builds against the Windows OS are currently failing and have been for a long time.

If we look back at the last time the workflow was run completely, this can be seen in the annotations below the summary, which show that the Windows test runs all failed.
https://github.com/phpDocumentor/ReflectionDocBlock/actions/runs/370378454

image

This was/is "hidden" due to the continue-on-error: true in the "Run PHPUnit" step in the unit test job, which will still mark the job as "passed", even though in reality it failed.


Details of the test failures (click to fold out)
There was 1 error:

1) phpDocumentor\Reflection\DocBlockFactoryTest::testTagsAreInterpretedUsingFactory
Mockery\Exception\NoMatchingExpectationException: No matching handler found for Mockery_1_phpDocumentor_Reflection_DocBlock_TagFactory::create('@author Mike van Riel <me@mikevanriel.com> This is with
  multiline description.', object(phpDocumentor\Reflection\Types\Context)). Either the method was unexpected or its arguments matched no expected argument list for this method

Objects: ( array (
  'phpDocumentor\\Reflection\\Types\\Context' => 
  array (
    'class' => 'phpDocumentor\\Reflection\\Types\\Context',
    'properties' => 
    array (
    ),
  ),
))

D:\a\ReflectionDocBlock\ReflectionDocBlock\src\DocBlockFactory.php:244
D:\a\ReflectionDocBlock\ReflectionDocBlock\src\DocBlockFactory.php:104
D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\unit\DocBlockFactoryTest.php:203

--

There were 11 failures:

1) phpDocumentor\Reflection\DocBlockFactoryTest::testDescriptionsRetainFormatting
Failed asserting that two objects are equal.
--- Expected
+++ Actual
@@ @@
 phpDocumentor\Reflection\DocBlock\Description Object (
-    'bodyTemplate' => 'This is a multiline Description\r\n
-    that contains a code block.\r\n
-    \r\n
+    'bodyTemplate' => 'This is a multiline Description\n
+    that contains a code block.\n
+    \n
         See here: a CodeBlock'
     'tags' => Array ()
 )

D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\unit\DocBlockFactoryTest.php:171

2) phpDocumentor\Reflection\DocBlock\DescriptionFactoryTest::testIfSuperfluousStartingSpacesAreRemoved
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
 'This is a multiline
 description that you commonly
 see with tags.
-
+
     It does have a multiline code sample
     that should align, no matter what
-
+
 All spaces superfluous spaces on the
 second and later lines should be
 removed but the code sample should
 still be indented.'

D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\unit\DocBlock\DescriptionFactoryTest.php:195

3) phpDocumentor\Reflection\DocBlock\SerializerTest::testReconstructsADocCommentFromADocBlock
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'/**
- * This is a summary
- *
- * This is a description
- *
- * @unknown-tag Test description for the unknown tag
+'/**
+ * This is a summary
+ *
+ * This is a description
+ *
+ * @unknown-tag Test description for the unknown tag
  */'

D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\unit\DocBlock\SerializerTest.php:66

4) phpDocumentor\Reflection\DocBlock\SerializerTest::testAddPrefixToDocBlock
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'aa/**
-aa * This is a summary
-aa *
-aa * This is a description
-aa *
-aa * @unknown-tag Test description for the unknown tag
+'aa/**
+aa * This is a summary
+aa *
+aa * This is a description
+aa *
+aa * @unknown-tag Test description for the unknown tag
 aa */'

D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\unit\DocBlock\SerializerTest.php:101

5) phpDocumentor\Reflection\DocBlock\SerializerTest::testAddPrefixToDocBlockExceptFirstLine
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'/**
-aa * This is a summary
-aa *
-aa * This is a description
-aa *
-aa * @unknown-tag Test description for the unknown tag
+'/**
+aa * This is a summary
+aa *
+aa * This is a description
+aa *
+aa * @unknown-tag Test description for the unknown tag
 aa */'

D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\unit\DocBlock\SerializerTest.php:136

6) phpDocumentor\Reflection\DocBlock\SerializerTest::testWordwrapsAroundTheGivenAmountOfCharacters
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'/**
- * This is a
- * summary
- *
- * This is a
- * description
- *
- * @unknown-tag
- * Test
- * description
- * for the
- * unknown tag
+'/**
+ * This is a
+ * summary
+ *
+ * This is a
+ * description
+ *
+ * @unknown-tag
+ * Test
+ * description
+ * for the
+ * unknown tag
  */'

D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\unit\DocBlock\SerializerTest.php:177

7) phpDocumentor\Reflection\DocBlock\SerializerTest::testNoExtraSpacesAfterTagRemoval
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'/**
- * @unknown-tag
+'/**
+ * @unknown-tag
  */'

D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\unit\DocBlock\SerializerTest.php:201

8) phpDocumentor\Reflection\InterpretingDocBlocksTest::testInterpretingASimpleDocBlock
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'This is a Description. A Summary and Description are separated by either
-two subsequent newlines (thus a whiteline in between as can be seen in this
-example), or when the Summary ends with a dot (`.`) and some form of
+'This is a Description. A Summary and Description are separated by either
+two subsequent newlines (thus a whiteline in between as can be seen in this
+example), or when the Summary ends with a dot (`.`) and some form of
 whitespace.'

D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\integration\InterpretingDocBlocksTest.php:82

9) phpDocumentor\Reflection\InterpretingDocBlocksTest::testDescriptionsCanEscapeAtSignsAndClosingBraces
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'You can escape the @-sign by surrounding it with braces, for example: @. And escape a closing brace within an
-inline tag by adding an opening brace in front of it like this: }.
-
-Here are example texts where you can see how they could be used in a real life situation:
-
-    This is a text with an {@internal inline tag where a closing brace (}) is shown}.
-    Or an {@internal inline tag with a literal {@link} in it}.
-
+'You can escape the @-sign by surrounding it with braces, for example: @. And escape a closing brace within an
+inline tag by adding an opening brace in front of it like this: }.
+
+Here are example texts where you can see how they could be used in a real life situation:
+
+    This is a text with an {@internal inline tag where a closing brace (}) is shown}.
+    Or an {@internal inline tag with a literal {@link} in it}.
+
 Do note that an {@internal inline tag that has an opening brace ({) does not break out}.'

D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\integration\InterpretingDocBlocksTest.php:139

10) phpDocumentor\Reflection\ReconstitutingADocBlockTest::testReconstituteADocBlock
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'/**
- * This is an example of a summary.
- *
- * And here is an example of the description
- * of a DocBlock that can span multiple lines.
- *
- * @see \phpDocumentor\Reflection\DocBlock\StandardTagFactory
+'/**
+ * This is an example of a summary.
+ *
+ * And here is an example of the description
+ * of a DocBlock that can span multiple lines.
+ *
+ * @see \phpDocumentor\Reflection\DocBlock\StandardTagFactory
  */'

D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\integration\ReconstitutingADocBlockTest.php:41

11) phpDocumentor\Reflection\UsingTagsTest::testAddingYourOwnTagUsingAStaticMethodAsFactory
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'/**
- * This is an example of a summary.
- *
- * @my-tag I have a description
+'/**
+ * This is an example of a summary.
+ *
+ * @my-tag I have a description
  */'

D:\a\ReflectionDocBlock\ReflectionDocBlock\tests\integration\UsingTagsTest.php:48


Most of the test failures in the Windows builds are due to the git check out of the code being done with core.autocrlf true and the line endings in the "expected" value not matching the line endings in the "actual" value.

There are two ways to look at these failures:

  1. These are just test failures, line endings are of no consequence and should not be the concern of this repository.
    In that case, it could even be considered to remove the builds against Mac and Windows OSes completely.
  2. This is a failure in the actual functionality of the repo.
    In that case, the use of new lines in various places in the code base will probably need to be changed to using PHP_EOL instead or, alternatively, there should be a check on the new line type of the input received and this same new line type should be used everywhere where new lines are added.

Opinions ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions