-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Command line tool for XML sync testing between languages: tags, revta…
…g, PI, ws
- Loading branch information
André L F S Bacci
committed
Feb 14, 2025
1 parent
80d1314
commit ba3cfab
Showing
9 changed files
with
616 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php /* | ||
+----------------------------------------------------------------------+ | ||
| Copyright (c) 1997-2025 The PHP Group | | ||
+----------------------------------------------------------------------+ | ||
| This source file is subject to version 3.01 of the PHP license, | | ||
| that is bundled with this package in the file LICENSE, and is | | ||
| available through the world-wide-web at the following url: | | ||
| https://www.php.net/license/3_01.txt. | | ||
| If you did not receive a copy of the PHP license and are unable to | | ||
| obtain it through the world-wide-web, please send a note to | | ||
| license@php.net, so we can mail you a copy immediately. | | ||
+----------------------------------------------------------------------+ | ||
| Authors: André L F S Bacci <ae php.net> | | ||
+----------------------------------------------------------------------+ | ||
# Description | ||
Compare processing instructions usage between two XML files. */ | ||
|
||
require_once __DIR__ . '/libqa/all.php'; | ||
|
||
$argv = new ArgvParser( $argv ); | ||
$ignore = new OutputIgnore( $argv ); // may exit. | ||
$argv->complete(); | ||
|
||
$list = SyncFileList::load(); | ||
|
||
foreach ( $list as $file ) | ||
{ | ||
$source = $file->sourceDir . '/' . $file->file; | ||
$target = $file->targetDir . '/' . $file->file; | ||
$output = new OutputBuffer( "# qaxml.p" , $target , $ignore ); | ||
|
||
[ $s , $_ , $_ ] = XmlFrag::loadXmlFragmentFile( $source ); | ||
[ $t , $_ , $_ ] = XmlFrag::loadXmlFragmentFile( $target ); | ||
|
||
$s = XmlFrag::listNodes( $s , XML_PI_NODE ); | ||
$t = XmlFrag::listNodes( $t , XML_PI_NODE ); | ||
|
||
$s = extractPiData( $s ); | ||
$t = extractPiData( $t ); | ||
|
||
if ( implode( "\n" , $s ) == implode( "\n" , $t ) ) | ||
continue; | ||
|
||
$sideCount = array(); | ||
|
||
foreach( $s as $v ) | ||
$sideCount[$v] = [ 0 , 0 ]; | ||
foreach( $t as $v ) | ||
$sideCount[$v] = [ 0 , 0 ]; | ||
|
||
foreach( $s as $v ) | ||
$sideCount[$v][0] += 1; | ||
foreach( $t as $v ) | ||
$sideCount[$v][1] += 1; | ||
|
||
foreach( $sideCount as $k => $v ) | ||
if ( $v[0] != $v[1] ) | ||
$output->addDiff( $k , $v[0] , $v[1] ); | ||
|
||
$output->print(); | ||
} | ||
|
||
function extractPiData( array $list ) | ||
{ | ||
$ret = array(); | ||
foreach( $list as $elem ) | ||
$ret[] = "{$elem->target} {$elem->data}"; | ||
return $ret; | ||
} |
Oops, something went wrong.