From 9d62af7283d3a840423ec625610b645c9f0739d8 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Tue, 26 Sep 2017 23:02:48 +0200 Subject: [PATCH] cputest: Avoid calling json_reformat in cpu-parse.sh Various version of json_reformat use different number of spaces for indenting. Let's use a simple python reformatter to gain full control over the formatting for consistent results. Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- tests/cputestdata/cpu-parse.sh | 2 +- tests/cputestdata/cpu-reformat.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 tests/cputestdata/cpu-reformat.py diff --git a/tests/cputestdata/cpu-parse.sh b/tests/cputestdata/cpu-parse.sh index cd1ab024b3..96ff1074e0 100755 --- a/tests/cputestdata/cpu-parse.sh +++ b/tests/cputestdata/cpu-parse.sh @@ -42,7 +42,7 @@ json() while read; do $first || echo first=false - json_reformat <<<"$REPLY" | tr -s '\n' + $(dirname $0)/cpu-reformat.py <<<"$REPLY" done } diff --git a/tests/cputestdata/cpu-reformat.py b/tests/cputestdata/cpu-reformat.py new file mode 100755 index 0000000000..999ef1698c --- /dev/null +++ b/tests/cputestdata/cpu-reformat.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python2 + +import sys +import json + +dec = json.JSONDecoder() +data, pos = dec.raw_decode(sys.stdin.read()) +json.dump(data, sys.stdout, indent = 2, separators = (',', ': ')) +print -- GitLab