Skip to content

Commit

Permalink
Compare only ASCII characters when matching table contents
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Mar 15, 2019
1 parent 84d6d06 commit a3017c2
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 10 deletions.
8 changes: 7 additions & 1 deletion test/support/devices_selector_context.rb
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions test/support/storage_helpers.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/y2partitioner/widgets/pages/bcaches_test.rb
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion test/y2partitioner/widgets/pages/btrfs_test.rb
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/y2partitioner/widgets/pages/disks_test.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/y2partitioner/widgets/pages/lvm_test.rb
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion test/y2partitioner/widgets/pages/lvm_vg_test.rb
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/y2partitioner/widgets/pages/md_raids_test.rb
Expand Up @@ -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) }
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/y2partitioner/widgets/pages/system_test.rb
Expand Up @@ -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]) }
Expand Down

0 comments on commit a3017c2

Please sign in to comment.