Allow ', ' as a separator for the lists & files as this is the output format.
Allow a line finishing by ', ', ' ,' and ',' in the file.

Visibility: low
Risk: low

Signed-off-by: Jean-Marc Eurin <jmeurin@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@2101 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/cli/topic_common_unittest.py b/cli/topic_common_unittest.py
index 7f57343..30882fc 100755
--- a/cli/topic_common_unittest.py
+++ b/cli/topic_common_unittest.py
@@ -91,6 +91,28 @@
         os.unlink(options.filename)
 
 
+    def test_file_list_one_line_comma_space(self):
+        class opt(object):
+            filename = cli_mock.create_file('a, b c\nd,e\nf\ng h,i')
+        options = opt()
+        self.assertEqualNoOrder(['a', 'b', 'c', 'd', 'e',
+                                 'f', 'g', 'h', 'i'],
+                                self.atest._file_list(options,
+                                                      opt_file='filename'))
+        os.unlink(options.filename)
+
+
+    def test_file_list_line_end_comma_space(self):
+        class opt(object):
+            filename = cli_mock.create_file('a, b c\nd,e, \nf,\ng h,i ,')
+        options = opt()
+        self.assertEqualNoOrder(['a', 'b', 'c', 'd', 'e',
+                                 'f', 'g', 'h', 'i'],
+                                self.atest._file_list(options,
+                                                      opt_file='filename'))
+        os.unlink(options.filename)
+
+
     def test_file_list_no_eof(self):
         class opt(object):
             filename = cli_mock.create_file('a\nb\nc')
@@ -138,6 +160,24 @@
                                                       opt_list='alist'))
 
 
+    def test_file_list_opt_list_mix_comma_space(self):
+        class opt(object):
+            alist = 'a b,c, d e'
+        options = opt()
+        self.assertEqualNoOrder(['a', 'b', 'c', 'd', 'e'],
+                                self.atest._file_list(options,
+                                                      opt_list='alist'))
+
+
+    def test_file_list_opt_list_end_comma_space(self):
+        class opt(object):
+            alist = 'a b, ,c,, d e, '
+        options = opt()
+        self.assertEqualNoOrder(['a', 'b', 'c', 'd', 'e'],
+                                self.atest._file_list(options,
+                                                      opt_list='alist'))
+
+
     def test_file_list_add_on_space(self):
         class opt(object):
             pass
@@ -157,6 +197,26 @@
                                                               'b,d']))
 
 
+    def test_file_list_add_on_mix_comma_space(self):
+        class opt(object):
+            pass
+        options = opt()
+        self.assertEqualNoOrder(['a', 'b', 'c', 'd'],
+                                self.atest._file_list(options,
+                                                      add_on=['a', 'c',
+                                                              'b,', 'd']))
+
+
+    def test_file_list_add_on_end_comma_space(self):
+        class opt(object):
+            pass
+        options = opt()
+        self.assertEqualNoOrder(['a', 'b', 'c', 'd'],
+                                self.atest._file_list(options,
+                                                      add_on=['a', 'c', 'b,',
+                                                              'd,', ',']))
+
+
     def test_file_list_all_opt(self):
         class opt(object):
             afile = cli_mock.create_file('f\ng\nh\n')
@@ -214,6 +274,19 @@
                                                       add_on=['i','j,d']))
 
 
+    def test_file_list_all_opt_in_common_weird(self):
+        class opt(object):
+            afile = cli_mock.create_file('a b c\nd,e\nf\ng, \n, ,,')
+            alist = 'a b,c,d h, ,  ,,	'
+        options = opt()
+        self.assertEqualNoOrder(['a', 'b', 'c', 'd', 'e',
+                                 'f', 'g', 'h', 'i', 'j'],
+                                self.atest._file_list(options,
+                                                      opt_file='afile',
+                                                      opt_list='alist',
+                                                      add_on=['i','j,d']))
+
+
     def test_invalid_arg_kill(self):
         self.atest.kill_on_failure = True
         self.god.mock_io()