Bug 11480 - Tests in Output_JSON.t make invalid assumptions
Summary: Tests in Output_JSON.t make invalid assumptions
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Colin Campbell
QA Contact: Galen Charlton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-06 16:51 UTC by Colin Campbell
Modified: 2014-12-07 20:07 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Proposed Patch (2.41 KB, patch)
2014-01-06 17:06 UTC, Colin Campbell
Details | Diff | Splinter Review
Bug 11480 Fix invalid assumptions in test (2.65 KB, patch)
2014-01-07 01:31 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 11480 Fix invalid assumptions in test (2.71 KB, patch)
2014-01-10 14:55 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Campbell 2014-01-06 16:51:44 UTC
Output_JSON.t fails on current perl release.
Tests in Output_JSON.t assume that items in the generated json string will be in a consistent order. Internally, though, they are held in a hash, an unordered container. In perl versions 5.18 and greater the overhaul of of hashing ensures that hash elements are returned in an unpredictable sequence, (which was previously the theory). As a result the tests checking the output should be rewitten not to make assumptions about the order of elements.
Comment 1 Colin Campbell 2014-01-06 17:06:09 UTC Comment hidden (obsolete)
Comment 2 Chris Cormack 2014-01-07 01:31:47 UTC Comment hidden (obsolete)
Comment 3 Kyle M Hall (khall) 2014-01-10 14:55:43 UTC
Created attachment 24136 [details] [review]
Bug 11480 Fix invalid assumptions in test

Tests for Output::JSON made the invalid assumption
that the hash keys of the modules internal structure
will always be returned in the same sequence.
A hash is an unordered structure. as of perl 5.18
this has beem reinforced by random seeding of the
hashing function. See the info in perldelta and
the doc for JSON

This patch changes the tests to be sequence neutral
where the previous test was testing that a new element
was added and an existing one was untouched these have
been separated into individual tests.
Some typos in the messages have been corrected

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Test Plan

1/ Run t/Output_JSONStream.t , 8 tests should pass (or perhaps fail, but inconsistently
under perl 5.18 or greater)
2/ Apply patch
3/ Run t/Output_JSONStream.t 10 tests should pass now

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 4 Galen Charlton 2014-01-10 16:14:49 UTC
Pushed to master.  Thanks, Colin!