Repository: coala/coala

Issue:
coala-ci doesn't use fail_aqcuire_settings



Discussion:
Actually this is a bug in coala.py of the default parameter of the coala_main routine. It does nothing by default while it could use the fail_acquire_settings method. To reproduce, use a section with e.g. the SpaceConsistencyBear and don't provide the use_spaces setting, when executing any noninteractive coala binary, you'll get:

```
255 lasse@lssteady ~/prog/coala (git)-[sils/tests] % coala-json -L DEBUG                                                                                                                                        :(
{
  "logs": [
    {
      "log_level": 3,
      "message": "An unknown error occurred. This is a bug. We are sorry for the inconvenience. Please contact the developers for assistance. During execution of coala an exception was raised. This should never happen. When asked for, the following information may help investigating:",
      "timestamp": "2015-11-20T12:56:26.913013"
    },
    {
      "log_level": 0,
      "message": "Exception was:\nTraceback (most recent call last):\n\n  File \"/usr/lib/python3.5/site-packages/coalib/coala_main.py\", line 64, in run_coala\n    targets) = gather_configuration(acquire_settings, log_printer)\n\n  File \"/usr/lib/python3.5/site-packages/coalib/settings/ConfigurationGathering.py\", line 222, in gather_configuration\n    log_printer)\n\n  File \"/usr/lib/python3.5/site-packages/coalib/settings/SectionFilling.py\", line 41, in fill_settings\n    fill_section(section, acquire_settings, log_printer, all_bears)\n\n  File \"/usr/lib/python3.5/site-packages/coalib/settings/SectionFilling.py\", line 94, in fill_section\n    for setting, help_text in new_vals.items():\n\nAttributeError: 'bool' object has no attribute 'items'",
      "timestamp": "2015-11-20T12:56:26.913033"
    }
  ],
  "results": null
}
255 lasse@lssteady ~/prog/coala (git)-[sils/tests] % coala-ci -L DEBUG                                                                                                                                          :(
[ERROR][12:56:32] An unknown error occurred. This is a bug. We are sorry for the inconvenience. Please contact the developers for assistance. During execution of coala an exception was raised. This should never happen. When asked for, the following information may help investigating:
[DEBUG][12:56:32] Exception was:
Traceback (most recent call last):

  File "/usr/lib/python3.5/site-packages/coalib/coala_main.py", line 64, in run_coala
    targets) = gather_configuration(acquire_settings, log_printer)

  File "/usr/lib/python3.5/site-packages/coalib/settings/ConfigurationGathering.py", line 222, in gather_configuration
    log_printer)

  File "/usr/lib/python3.5/site-packages/coalib/settings/SectionFilling.py", line 41, in fill_settings
    fill_section(section, acquire_settings, log_printer, all_bears)

  File "/usr/lib/python3.5/site-packages/coalib/settings/SectionFilling.py", line 94, in fill_section
    for setting, help_text in new_vals.items():

AttributeError: 'bool' object has no attribute 'items'
255 lasse@lssteady ~/prog/coala (git)-[sils/tests] %  
```

s/coala.py/coala_main.py/g

Solution is pretty straightforward: use the fail_aqcuire_settings method in run_coala as default argument for run_coala, that should fix it. Ideally add a testcase in coalaTest.


Resolving patch:
diff --git a/coalib/coala_main.py b/coalib/coala_main.py
--- a/coalib/coala_main.py
+++ b/coalib/coala_main.py
@@ -9,6 +9,7 @@
 from coalib.misc.Exceptions import get_exitcode
 from coalib.bears.BEAR_KIND import BEAR_KIND
 from coalib.collecting.Collectors import collect_bears
+from coalib.output.Interactions import fail_acquire_settings
 from coalib.output.Tagging import tag_results, delete_tagged_results
 
 
@@ -17,7 +18,7 @@
 
 def run_coala(log_printer=None,
               print_results=do_nothing,
-              acquire_settings=do_nothing,
+              acquire_settings=fail_acquire_settings,
               print_section_beginning=do_nothing,
               nothing_done=do_nothing,
               show_bears=do_nothing):


Test patch:
diff --git a/coalib/tests/coalaTest.py b/coalib/tests/coalaTest.py
--- a/coalib/tests/coalaTest.py
+++ b/coalib/tests/coalaTest.py
@@ -78,6 +78,12 @@ def test_tagging(self):
         execute_coala_ci(("-S", "dtag=test_tag", "-c", self.coafile))
         self.assertFalse(os.path.exists(tag_path))
 
+    def test_fail_acquire_settings(self):
+        """It raises an AssertionError when required settings are missing."""
+        retval, output = execute_coala_ci((
+            "-b", 'SpaceConsistencyBear', '-c', '/dev/null'))
+        self.assertIn("During execution, we found that some", output)
+
 
 if __name__ == '__main__':
     unittest.main(verbosity=2)