Diff Tool Exercises
Paid subscribers get to play with these exercises together. Join us, Friday 10 January at 1pm, on Zoom.
diff
compares two files, highlighting differences. Here's how diff
can work for testers. On that page, you'll find links to several tools that implement and build on diff
– you may already have your own preference.
In this exercise, you’ll use any diff tool that seems right to you.
This exercise is more fun in a group. If you’re in a group, please talk about what tool you’d use. Perhaps re-run the exercise with someone else’s tool of choice, or with someone else.
The solutions are below. The tool will do most of the work – give yourself kudos for spotting non-trivial things. Zero kudos if you look at the solutions before trying the exercises.
Exercises Group 1 – XML and JSON
Download the linked files, use them in a tool.
If you’re opening the file in a browser, finding out what an xmlschema is, and reading through it, you’re doing it …differently from how I’d expect you to do it.
Exercise 1.01 (XML)
Solution
Exercise 1.01 - Lines Removed
in the schema definition, v2 is missing these lines, location 453 in original
<xs:element name="BkPtyId" type="Max35Text" minOccurs="0" maxOccurs="1"/>
<xs:element name="TaxIdNb" type="Max35Text" minOccurs="0" maxOccurs="1"/>
Exercise 1.02 (XML)
Solution
Exercise 1.02 - Lines Added
In the schema definition, v2 has had line 699 duplicated in error
</xs:complexType>
Exercise 1.03 (XML)
Solution
Exercise 1.03 - Lines Rearranged
In the schema definintion on lines 224 to 234 of v2, SimpleType DocumentType2Code has been rearranged. Kudos if you recognised that it has been sorted
<xs:enumeration value="CINV"/>
<xs:enumeration value="CMCN"/>
<xs:enumeration value="CNFA"/>
<xs:enumeration value="CREN"/>
<xs:enumeration value="DEBN"/>
<xs:enumeration value="DISP"/>
<xs:enumeration value="DNFA"/>
<xs:enumeration value="HIRI"/>
<xs:enumeration value="MSIN"/>
<xs:enumeration value="SBIN"/>
<xs:enumeration value="SOAC"/>
Exercise 1.04 (XML)
Solution
Exercise 1.04 Information Changed On A Single Line
In the schema definition on line 463, the order of attributes has been rearranged. Kudos if you noticed that maxOccurs
has changed from 4 to 5
<xs:element name="PrvtId" minOccurs="1" maxOccurs="5" type="PersonIdentification3" />
Exercise 1.05 (XML)
Solution
Exercise 1.05 - Lines Split
In the schema definition on line 165, the line has been split by tag.
Kudos if you noticed that there’s an extra attribute base
, that the tag is no longer closed with />
but ends with a >
, and that the name
attribute is now ccy
rather than Ccy
<xs:attribute
name="ccy"
type="CurrencyCode"
base="xs:string"
use="required">
Exercise 1.06 (XML)
Solution
Exercise 1.06 - Lines Joined
In the schema definition, line 278 has been joined with line 279. Kudos if you noticed the spelling of elemnet
, the absence of capitalisation in both pairs of maxoccurs
and minoccurs
, and at least one spellign error.
<xs:element name="ClrSysMmbId" type="ClearingSystemMemberIdentification3Choice" minoccurs="0" maxoccurs="1"/><xs:elemnet name="Nm" type="Max70Text" minocurrs="0" maxoccurs="1"/>
Exercise 1.07 (JSON)
Solution
Exercise 1.07 - data changed
On line 632, the value has an extra decimal place. Kudos if you noticed the small change in property name entryCustom4OCode
.
"entryCustom4OCode": "20.000000000",
On 892, the cardTransactionReferenceNumber
is ""
rather than null
.
"cardTransactionReferenceNumber": "",
Exercise 1.08 (JSON)
Solution
Exercise 1.08 - line added
Line 346 in the second file does not exist in the first file.
"nextPage": null
Kudos if you noticed that it is missing the trailing comma, making the JSON invalid.
Exercise 1.09 (JSON)
Solution
Exercise 1.09 - lines missing
Line 46-48 , 67-69, 126-128 and 298-300 in the first are missing in the second.
"employeeCustom19Code": null,
"employeeCustom20Code": null,
"employeeCustom21Code": null,
"employeeCustom19Value": null,
"employeeCustom20Value": null,
"employeeCustom21Value": null
"reportCustom18Code": null,
"reportCustom19Code": null,
"reportCustom20Code": null,
"allocationCustom18Code": null,
"allocationCustom19Code": null,
"allocationCustom20Code": null,
Kudos if you noticed that line 66 correctly omits the trailing comma, so the JSON is valid although the data is missing.
Kudos if you wondered why entryCustomCode
has been left untouched.
Exercise 1.10 (JSON)
Why have I given you two file 2s? Can you see any differences?
Solution
Exercise 1.10 - values changed, alternative formats
The second file has a new blank line at line 71
The second document status is marked "Pending" rather than "READY" on line 358
"docStatus": "Pending"
Kudos if you wondered why Pending
is not in upper case.
Kudos if you spotted that while file1 and file 2 have identical contents, they are rather different sizes. More kudos if you noticed their encoding is different.
-rw-r--r--@ 1 james staff 14617 10 Jan 11:14 transaction_4_a.json
-rw-r--r--@ 1 james staff 14628 10 Jan 11:25 transaction_4_b.json
-rw-r--r--@ 1 james staff 29254 10 Jan 11:25 transaction_4_b2.json
james@Mac diff tool exercise % file -I transaction_4_b.json
transaction_4_b.json: text/plain; charset=utf-8
james@Mac diff tool exercise % file -I transaction_4_b2.json
transaction_4_b2.json: text/plain; charset=utf-16be
Your tool may not reveal this to you...
«JL: Add more, in CSV and TXT (i.e. dir list). »
Planned exercises include...
Exercises Group 2 – Code and config
Python, JavaScript, YAML/TOML, env
Exercises Group 3 – Markdown
Docs and readme.
Exercises Group 3 – Folders
Changed content, added / removed, renamed / moved, timestamp, permissions, ?encoding, ?os-specific metadata, ?hash,
Exercises Group 4 – Combos
sort / grep / filter – first, within git and across files for a commit, on directory / process lists, getting unique / count of changes,
This page is a work in progress. I'm sure that a curious reader can easily find my notes to myself. «JL: perhaps, if the script finds any notes, it can insert this message?»
Comments
Sign in or become a Workroom Productions member to read and leave comments.