mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Remove diff output from test runner - only report file differences
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
fb821ec443
commit
ce1fec0cb0
@ -6,31 +6,31 @@ import { execSync } from 'child_process';
|
|||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
// Logging functions following formatters/logging/README.md style
|
// Logging functions following formatters/logging/README.md style
|
||||||
function log_title(title: string): void {
|
function log_title (title: string): void {
|
||||||
console.error(`\x1b[1m${title}\x1b[0m`);
|
console.error(`\x1b[1m${title}\x1b[0m`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function log_action(action: string): void {
|
function log_action (action: string): void {
|
||||||
process.stderr.write(` ${action}... `);
|
process.stderr.write(` ${action}... `);
|
||||||
}
|
}
|
||||||
|
|
||||||
function log_ok(): void {
|
function log_ok (): void {
|
||||||
console.error('\x1b[32m✓\x1b[0m');
|
console.error('\x1b[32m✓\x1b[0m');
|
||||||
}
|
}
|
||||||
|
|
||||||
function log_fail(): void {
|
function log_fail (): void {
|
||||||
console.error('\x1b[31m✗\x1b[0m');
|
console.error('\x1b[31m✗\x1b[0m');
|
||||||
}
|
}
|
||||||
|
|
||||||
function log_detail(detail: string): void {
|
function log_detail (detail: string): void {
|
||||||
console.error(`\x1b[90m${detail}\x1b[0m`);
|
console.error(`\x1b[90m${detail}\x1b[0m`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function log_summary(summary: string): void {
|
function log_summary (summary: string): void {
|
||||||
console.error(`\x1b[1m${summary}\x1b[0m`);
|
console.error(`\x1b[1m${summary}\x1b[0m`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanOutputDirectory(): void {
|
function cleanOutputDirectory (): void {
|
||||||
const outputDir = join(SPINE_ROOT, 'tests', 'output');
|
const outputDir = join(SPINE_ROOT, 'tests', 'output');
|
||||||
|
|
||||||
log_action('Cleaning output directory');
|
log_action('Cleaning output directory');
|
||||||
@ -47,7 +47,7 @@ function cleanOutputDirectory(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNewestFileTime(directory: string, pattern: string): number {
|
function getNewestFileTime (directory: string, pattern: string): number {
|
||||||
try {
|
try {
|
||||||
const files = execSync(`find "${directory}" -name "${pattern}" -type f`, { encoding: 'utf8' })
|
const files = execSync(`find "${directory}" -name "${pattern}" -type f`, { encoding: 'utf8' })
|
||||||
.trim()
|
.trim()
|
||||||
@ -68,7 +68,7 @@ function getNewestFileTime(directory: string, pattern: string): number {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function needsJavaBuild(): boolean {
|
function needsJavaBuild (): boolean {
|
||||||
const javaDir = join(SPINE_ROOT, 'spine-libgdx');
|
const javaDir = join(SPINE_ROOT, 'spine-libgdx');
|
||||||
const testDir = join(javaDir, 'spine-libgdx-tests');
|
const testDir = join(javaDir, 'spine-libgdx-tests');
|
||||||
const buildDir = join(testDir, 'build', 'libs');
|
const buildDir = join(testDir, 'build', 'libs');
|
||||||
@ -93,7 +93,7 @@ function needsJavaBuild(): boolean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function needsCppBuild(): boolean {
|
function needsCppBuild (): boolean {
|
||||||
const cppDir = join(SPINE_ROOT, 'spine-cpp');
|
const cppDir = join(SPINE_ROOT, 'spine-cpp');
|
||||||
const buildDir = join(cppDir, 'build');
|
const buildDir = join(cppDir, 'build');
|
||||||
const headlessTest = join(buildDir, 'headless-test');
|
const headlessTest = join(buildDir, 'headless-test');
|
||||||
@ -135,7 +135,7 @@ interface SkeletonFiles {
|
|||||||
atlasPath: string;
|
atlasPath: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findSkeletonFiles(skeletonName: string): SkeletonFiles {
|
function findSkeletonFiles (skeletonName: string): SkeletonFiles {
|
||||||
const examplesDir = join(SPINE_ROOT, 'examples', skeletonName);
|
const examplesDir = join(SPINE_ROOT, 'examples', skeletonName);
|
||||||
const exportDir = join(examplesDir, 'export');
|
const exportDir = join(examplesDir, 'export');
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ function findSkeletonFiles(skeletonName: string): SkeletonFiles {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateArgs(): { language: string; files?: SkeletonFiles; skeletonPath?: string; atlasPath?: string; animationName?: string; fixFloats?: boolean } {
|
function validateArgs (): { language: string; files?: SkeletonFiles; skeletonPath?: string; atlasPath?: string; animationName?: string; fixFloats?: boolean } {
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
@ -256,7 +256,7 @@ function validateArgs(): { language: string; files?: SkeletonFiles; skeletonPath
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function executeJava(args: TestArgs): string {
|
function executeJava (args: TestArgs): string {
|
||||||
const javaDir = join(SPINE_ROOT, 'spine-libgdx');
|
const javaDir = join(SPINE_ROOT, 'spine-libgdx');
|
||||||
const testDir = join(javaDir, 'spine-libgdx-tests');
|
const testDir = join(javaDir, 'spine-libgdx-tests');
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ function executeJava(args: TestArgs): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function executeCpp(args: TestArgs): string {
|
function executeCpp (args: TestArgs): string {
|
||||||
const cppDir = join(SPINE_ROOT, 'spine-cpp');
|
const cppDir = join(SPINE_ROOT, 'spine-cpp');
|
||||||
const testsDir = join(cppDir, 'tests');
|
const testsDir = join(cppDir, 'tests');
|
||||||
|
|
||||||
@ -373,7 +373,7 @@ function executeCpp(args: TestArgs): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseOutput(output: string): { skeletonData: any, skeletonState: any, animationState?: any } {
|
function parseOutput (output: string): { skeletonData: any, skeletonState: any, animationState?: any } {
|
||||||
// Split output into sections
|
// Split output into sections
|
||||||
const sections = output.split(/=== [A-Z ]+? ===/);
|
const sections = output.split(/=== [A-Z ]+? ===/);
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ function parseOutput(output: string): { skeletonData: any, skeletonState: any, a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixFloatsAndPropertyIds(target: any, reference: any, path: string = '', targetLanguage: string = 'cpp'): any {
|
function fixFloatsAndPropertyIds (target: any, reference: any, path: string = '', targetLanguage: string = 'cpp'): any {
|
||||||
// Handle null values
|
// Handle null values
|
||||||
if (reference === null || target === null) return target;
|
if (reference === null || target === null) return target;
|
||||||
|
|
||||||
@ -469,7 +469,7 @@ function fixFloatsAndPropertyIds(target: any, reference: any, path: string = '',
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveJsonFiles(args: TestArgs, parsed: any, javaParsed?: any, fixFloats?: boolean): void {
|
function saveJsonFiles (args: TestArgs, parsed: any, javaParsed?: any, fixFloats?: boolean): void {
|
||||||
// Ensure output directory exists
|
// Ensure output directory exists
|
||||||
const outputDir = join(SPINE_ROOT, 'tests', 'output');
|
const outputDir = join(SPINE_ROOT, 'tests', 'output');
|
||||||
if (!existsSync(outputDir)) {
|
if (!existsSync(outputDir)) {
|
||||||
@ -502,7 +502,7 @@ function saveJsonFiles(args: TestArgs, parsed: any, javaParsed?: any, fixFloats?
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function runTestsForFiles(language: string, skeletonPath: string, atlasPath: string, animationName?: string, fixFloats?: boolean): void {
|
function runTestsForFiles (language: string, skeletonPath: string, atlasPath: string, animationName?: string, fixFloats?: boolean): void {
|
||||||
const testArgs: TestArgs = {
|
const testArgs: TestArgs = {
|
||||||
language,
|
language,
|
||||||
skeletonPath,
|
skeletonPath,
|
||||||
@ -533,7 +533,7 @@ function runTestsForFiles(language: string, skeletonPath: string, atlasPath: str
|
|||||||
saveJsonFiles(testArgs, targetParsed, javaParsed, fixFloats);
|
saveJsonFiles(testArgs, targetParsed, javaParsed, fixFloats);
|
||||||
}
|
}
|
||||||
|
|
||||||
function verifyOutputsMatch(): void {
|
function verifyOutputsMatch (): void {
|
||||||
const outputDir = join(SPINE_ROOT, 'tests', 'output');
|
const outputDir = join(SPINE_ROOT, 'tests', 'output');
|
||||||
const outputFiles = [
|
const outputFiles = [
|
||||||
'skeleton-data-java-json.json',
|
'skeleton-data-java-json.json',
|
||||||
@ -571,16 +571,6 @@ function verifyOutputsMatch(): void {
|
|||||||
if (javaContent !== cppContent) {
|
if (javaContent !== cppContent) {
|
||||||
allMatch = false;
|
allMatch = false;
|
||||||
console.error(`\n❌ Files differ: ${javaFile} vs ${cppFile}`);
|
console.error(`\n❌ Files differ: ${javaFile} vs ${cppFile}`);
|
||||||
|
|
||||||
// Show diff using system diff command
|
|
||||||
try {
|
|
||||||
execSync(`diff "${join(outputDir, javaFile)}" "${join(outputDir, cppFile)}"`, {
|
|
||||||
stdio: 'inherit',
|
|
||||||
cwd: outputDir
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
// diff exits with code 1 when files differ, which is expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
allMatch = false;
|
allMatch = false;
|
||||||
@ -597,7 +587,7 @@ function verifyOutputsMatch(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function main(): void {
|
function main (): void {
|
||||||
const args = validateArgs();
|
const args = validateArgs();
|
||||||
|
|
||||||
log_title('Spine Runtime Test');
|
log_title('Spine Runtime Test');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user