diff options
author | Joe Wilm <jwilm@users.noreply.github.com> | 2018-09-17 08:15:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-17 08:15:20 -0700 |
commit | cff58e9d683c44a34f37e628c7faaea4410ada74 (patch) | |
tree | e051a942190247faeab42757dd6a5f08db5a7cca /scripts/migrate_ref_tests.rb | |
parent | 865727c062810e29fa33b5c04bb05510e7da3ddf (diff) | |
parent | 054e38e98d8f150b99b50fec9f679c3d23875a0a (diff) | |
download | alacritty-cff58e9d683c44a34f37e628c7faaea4410ada74.tar.gz alacritty-cff58e9d683c44a34f37e628c7faaea4410ada74.zip |
Merge pull request #1147 from jwilm/scrollbackv0.2.0
Scrollback
Diffstat (limited to 'scripts/migrate_ref_tests.rb')
-rwxr-xr-x | scripts/migrate_ref_tests.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/migrate_ref_tests.rb b/scripts/migrate_ref_tests.rb new file mode 100755 index 00000000..5ed02893 --- /dev/null +++ b/scripts/migrate_ref_tests.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +require 'json' + +Dir.glob('./tests/ref/**/grid.json').each do |path| + puts "Migrating #{path}" + + # Read contents + s = File.open(path) { |f| f.read } + + # Parse + grid = JSON.parse(s) + + # Normalize Storage serialization + if grid['raw'].is_a? Array + grid['raw'] = { + 'inner' => grid['raw'][0], + 'zero' => grid['raw'][1], + 'visible_lines' => grid['raw'][2] + } + end + + # Migrate Row serialization + grid['raw']['inner'].map! do |row| + if row.is_a? Hash + row + else + { inner: row, occ: row.length } + end + end + + # Write updated grid + File.open(path, 'w') { |f| f << JSON.generate(grid) } +end |