The text files comparison will compare files without a structure, such as reports or log files. More precisely, it will compare either all files with the same path inside two folders defined in the configuration, or two files defined in the configuration.
The lines in the text files are compared as a whole, since there is no structure. Some portions may be ignored using options and/or regular expressions.
A minimal bacmp configuration file for text files will be as below. It will scan the default left and right folders and compare each file found with the same name.
{"comparisonType“: "Textfile“}
By default, the tool will compare all pairs of files with the same path in the left folder and the right folder. This means that if a file appears in both folders, or in the same subfolder in both folders, they will be compared. You can also supply two options ‘leftFile’ and ‘rightFile’. In this case, the folders are disregarded and only the two files are compared. This enables you to compare files with different names. See Additional properties for the exact syntax.
If nothing else is specified, the lines in the files are rejected as a whole if they are different. Property files may be added to the comparison to define exceptions. These may be defined at several levels:
Common property files can be specified as semicolon-separated files using the ‘propertiesFiles’ option in the configuration. Specific property files can also be added at folder or file level (‘regularExpressionsFilesMapping’ option).
{
"comparisonType“: "Textfile",
"textFile": {
"propertiesFiles": "compare/data/p1.properties;compare/data/p2.properties",
"regularExpressionsFilesMapping": {
"folder1": ["compare/data/p1.properties","compare/data/p2.properties"], "folder2/file1": ["compare/data/p1.properties"] } ... }
}
In file mode, only the ‘propertiesFile’ option is used.
In folder mode, “propertiesFile” option is used first, then additional properties files may be used, taken into account in this order:
The properties syntax is as follows: one or more regular expressions are matched with a replacement value. regex=<regex1> regex=<regex2> ... value=<replacement>
For instance, these values: regex=Date: [0-9]{4}/[0-9]{2}/[0-9]{2} ([a-zA-Z0-9-\.\(\) ]{100}) value=Date: xxxx/xx/xx $1
will allow to replace some dates and thus ignore the corresponding date differences in a report. This avoids comparing acceptable differences such as the dates which differ due to a different execution date of the test case.
In addition to the configurations above, there are additional properties. Most have default values that are used if the property does not appear in the file, but can also be specified to another value. Others are not used if left unspecified.
Default values are written in green below when they exist, a red ‘no value’ otherwise.
fileFilter | Comma-separated extension list to compare. For instance, setting to "txt" will compare only the txt in the folders. If enablePdfConversion is not disabled, the pdfs are automatically compared regardless of this option. This option is ignored in file mode. | |
propertiesFiles | Common property files | See Filter options |
regularExpressionsFilesMapping | Explicit property files mappings | See Filter options |
leftFolder | Customize the left folder for the files to compare | |
rightFolder | Customize the right folder for the files to compare | |
leftFile | Specify a left file to be compared (file mode) | See Folder mode and file mode |
rightFile | Specify a right file to be compared (file mode) | See Folder mode and file mode |
folderFileFilterName | Default name for the properties files in folders | See Filter options |
enablePdfConversion | Whether to automatically convert Pdfs to txt so as to compare them. Necessary to compare PDFs | See Additional properties |
keepConvertedTextFiles | If used, the temporary txt files coming from PDF conversion will be kept (useful for debugging) | |
convertedTextFilesFolder | If keepConvertedTextFiles is used, the temporary txt files coming from PDF conversion are stored in this folder. |