From a3017c2e3e44cd76c194e3f0a2e92dff5c2741ae Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Fri, 15 Mar 2019 10:25:46 +0100 Subject: [PATCH] Compare only ASCII characters when matching table contents --- test/support/devices_selector_context.rb | 8 +++++++- test/support/storage_helpers.rb | 4 ++++ test/y2partitioner/widgets/pages/bcaches_test.rb | 2 +- test/y2partitioner/widgets/pages/btrfs_test.rb | 2 +- test/y2partitioner/widgets/pages/disks_test.rb | 4 ++-- test/y2partitioner/widgets/pages/lvm_test.rb | 2 +- test/y2partitioner/widgets/pages/lvm_vg_test.rb | 2 +- test/y2partitioner/widgets/pages/md_raids_test.rb | 4 ++-- test/y2partitioner/widgets/pages/system_test.rb | 2 +- 9 files changed, 20 insertions(+), 10 deletions(-) diff --git a/test/support/devices_selector_context.rb b/test/support/devices_selector_context.rb index 9d876f314b..17dc8b47f0 100644 --- a/test/support/devices_selector_context.rb +++ b/test/support/devices_selector_context.rb @@ -25,8 +25,14 @@ def dev(name) Y2Storage::BlkDevice.find_by_name(current_graph, name) end + def column_match?(column, regexp) + if column.respond_to?(:match?) + bidi_strip(column).match?(regexp) + end + end + def row_match?(row, regexp) - row.any? { |column| column.respond_to?(:match?) && column.match?(regexp) } + row.any? { |column| column_match?(column, regexp) } end def rows_match?(rows, *args) diff --git a/test/support/storage_helpers.rb b/test/support/storage_helpers.rb index 526499bc8d..ef29846710 100644 --- a/test/support/storage_helpers.rb +++ b/test/support/storage_helpers.rb @@ -220,6 +220,10 @@ def crypttab_entry(*values) def stub_product_features(features) Yast::ProductFeatures.Import(features) end + + def bidi_strip(s) + s.gsub(/[^[:ascii:]]*/, "") # filter out BiDi formatting + end end # rubocop:enable all end diff --git a/test/y2partitioner/widgets/pages/bcaches_test.rb b/test/y2partitioner/widgets/pages/bcaches_test.rb index f88a695f4f..682180325c 100644 --- a/test/y2partitioner/widgets/pages/bcaches_test.rb +++ b/test/y2partitioner/widgets/pages/bcaches_test.rb @@ -69,7 +69,7 @@ expect(table).to_not be_nil - devices = table.items.map { |i| i[1] } + devices = table.items.map { |i| bidi_strip(i[1]) } expect(devices).to contain_exactly("/dev/bcache0", "/dev/bcache1", "/dev/bcache2", "/dev/bcache0p1", "/dev/bcache2p1") diff --git a/test/y2partitioner/widgets/pages/btrfs_test.rb b/test/y2partitioner/widgets/pages/btrfs_test.rb index d0e241def6..7e55826a9a 100644 --- a/test/y2partitioner/widgets/pages/btrfs_test.rb +++ b/test/y2partitioner/widgets/pages/btrfs_test.rb @@ -52,7 +52,7 @@ expect(table.items.size).to eq(5) devices_name = btrfs_devices.map(&:name) - items_name = table.items.map { |i| i[1] } + items_name = table.items.map { |i| bidi_strip(i[1]) } expect(items_name.sort).to eq(devices_name.sort) end diff --git a/test/y2partitioner/widgets/pages/disks_test.rb b/test/y2partitioner/widgets/pages/disks_test.rb index 645c262fc8..06380d80d2 100644 --- a/test/y2partitioner/widgets/pages/disks_test.rb +++ b/test/y2partitioner/widgets/pages/disks_test.rb @@ -50,7 +50,7 @@ expect(table).to_not be_nil devices_name = disks_and_parts.map(&:name) - items_name = table.items.map { |i| i[1] } + items_name = table.items.map { |i| bidi_strip(i[1]) } expect(items_name.sort).to eq(devices_name.sort) end @@ -64,7 +64,7 @@ it "shows a table with the disk devices, their partitions and the Xen virtual partitions" do devices = disks_and_parts + device_graph.stray_blk_devices devices_name = devices.map(&:name) - items_name = table.items.map { |i| i[1] } + items_name = table.items.map { |i| bidi_strip(i[1]) } expect(items_name.sort).to eq(devices_name.sort) end diff --git a/test/y2partitioner/widgets/pages/lvm_test.rb b/test/y2partitioner/widgets/pages/lvm_test.rb index 345dbfdbe8..07dd8aa5b1 100644 --- a/test/y2partitioner/widgets/pages/lvm_test.rb +++ b/test/y2partitioner/widgets/pages/lvm_test.rb @@ -23,7 +23,7 @@ let(:table) { widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::LvmDevicesTable) } } - let(:items) { table.items.map { |i| i[1] } } + let(:items) { table.items.map { |i| bidi_strip(i[1]) } } before do vg = Y2Storage::LvmVg.find_by_vg_name(current_graph, "vg0") diff --git a/test/y2partitioner/widgets/pages/lvm_vg_test.rb b/test/y2partitioner/widgets/pages/lvm_vg_test.rb index c87dba47d4..ffd2472681 100644 --- a/test/y2partitioner/widgets/pages/lvm_vg_test.rb +++ b/test/y2partitioner/widgets/pages/lvm_vg_test.rb @@ -80,7 +80,7 @@ let(:table) { widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::LvmDevicesTable) } } - let(:items) { table.items.map { |i| i[1] } } + let(:items) { table.items.map { |i| bidi_strip(i[1]) } } before do create_thin_provisioning(lvm_vg) diff --git a/test/y2partitioner/widgets/pages/md_raids_test.rb b/test/y2partitioner/widgets/pages/md_raids_test.rb index 720585f33f..b5ea6e5bb3 100644 --- a/test/y2partitioner/widgets/pages/md_raids_test.rb +++ b/test/y2partitioner/widgets/pages/md_raids_test.rb @@ -24,7 +24,7 @@ let(:table) { widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::BlkDevicesTable) } } let(:buttons_set) { widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::DeviceButtonsSet) } } - let(:items) { table.items.map { |i| i[1] } } + let(:items) { table.items.map { |i| bidi_strip(i[1]) } } it "shows a button to add a raid" do button = widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::MdAddButton) } @@ -41,7 +41,7 @@ raids = current_graph.software_raids parts = raids.map(&:partitions).flatten.compact devices_name = (raids + parts).map(&:name) - items_name = table.items.map { |i| i[1] } + items_name = table.items.map { |i| bidi_strip(i[1]) } expect(items_name.sort).to eq(devices_name.sort) end diff --git a/test/y2partitioner/widgets/pages/system_test.rb b/test/y2partitioner/widgets/pages/system_test.rb index 5120b3e904..248089add6 100644 --- a/test/y2partitioner/widgets/pages/system_test.rb +++ b/test/y2partitioner/widgets/pages/system_test.rb @@ -26,7 +26,7 @@ def find_table(widgets) # Names from the devices in the list def row_names(table) - table.items.map { |i| i[1] } + table.items.map { |i| bidi_strip(i[1]) } end let(:widgets) { Yast::CWM.widgets_in_contents([subject]) }