Commits

Steve Losh committed 1d062fa

guts: Run the tests after installing a package.

  • Participants
  • Parent commits 83110ba

Comments (0)

Files changed (4)

File lib/gorilla/guts/catalog.py

     def build_commands(self):
         return self.module.__dict__.get('build_commands', [])
     
+    @property
+    def tests(self):
+        return self.module.__dict__.get('tests', {})
+    
 
 def all_cards():
     """Return a generator for all Cards in the catalog."""

File lib/gorilla/guts/cli.py

                 ui.error('Unknown package: %s\n' % exc.name)
                 continue
             
-            ui.write('Installing %s ...\n' % card.name)
+            ui.write('Installing %s (version: %s) ...\n' % (card.name,
+                opts['version']))
             
             shelf = Shelf(card)
-            shelf.install(opts['version'])
+            installed = shelf.install(opts['version'])
+            
+            if installed:
+                ui.write('Successfully installed %s.\n' % card.name)
+            else:
+                ui.error('There was a problem installing %s!\n' % card.name)
     else:
         ui.error('You must specify a package to install!\n')
 

File lib/gorilla/guts/repo.py

     def clone(self):
         command = ['hg', 'clone', self.sources[0], self.path, '--noupdate']
         
-        rc = subprocess.call(command, shell=False)
+        rc = subprocess.call(command, shell=False, stdout=subprocess.PIPE)
         return rc == 0
     
     def pull(self):
         command = ['hg', 'pull', '-R', self.path, self.sources[0]]
         
-        rc = subprocess.call(command, shell=False)
+        rc = subprocess.call(command, shell=False, stdout=subprocess.PIPE)
         return rc == 0
     
     def update(self, version):
         version = 'tip' if version == 'latest' else version
         command = ['hg', 'update', '-R', self.path, version]
         
-        rc = subprocess.call(command, shell=False)
+        rc = subprocess.call(command, shell=False, stdout=subprocess.PIPE)
         return rc == 0
     
     @property

File lib/gorilla/guts/shelf.py

         self.repo.update(version)
         
         for command in self.card.build_commands:
-            subprocess.call(command, shell=True, cwd=self.path)
+            proc = subprocess.Popen(command, shell=True, cwd=self.path,
+                stdout=subprocess.PIPE)
+            proc.wait()
         
         if not self.installed:
             for package in self.card.packages:
                 source = os.path.join(self.path, script)
                 dest = os.path.join(util.BIN_PATH, script)
                 os.symlink(source, dest)
+        
+        for test, expected_output in self.card.tests.iteritems():
+            expected_output = re.compile(expected_output, re.MULTILINE)
+            proc = subprocess.Popen(test, shell=True, stdout=subprocess.PIPE)
+            
+            output = proc.communicate()[0]
+            if not expected_output.match(output):
+                return False
+        
+        return True