def test_no_mode_error(self): message = None try: run(StringIO(), []) except InvalidArgumentsError as e: message = e.args[0] assert('No mode specified' == message)
def test_unknown_mode_error(self): message = None try: run(StringIO(), ['foo']) except InvalidArgumentsError as e: message = e.args[0] assert('Unknown mode \'{}\''.format('foo') == message)
def test_no_config_error(self): caught = False try: run(StringIO(), ['walk', 'foo']) except NoConfigError as e: caught = True assert(caught)
def test_no_config_error(self): with self.assertRaises(NoConfigError): run(None, None, None, None, None, ['walk', 'foo']) stderr = StringIO() main(None, stderr, None, None, None, [__name__, 'walk', 'foo']) assert(stderr.getvalue())
def test_invalid_path_error(self): with self.assertRaises(InvalidPathError): run(None, None, None, None, None, ['walk', 'foo']) stderr = StringIO() main(None, stderr, None, None, None, [__name__, 'walk', 'foo']) assert (stderr.getvalue())
def test_no_config_error(self): with self.assertRaises(NoConfigError): run(None, None, None, None, None, ['walk', 'foo']) stderr = StringIO() main(None, stderr, None, None, None, [__name__, 'walk', 'foo']) assert (stderr.getvalue())
def test_graph(self): f = StringIO() run(f, None, None, None, None, ['dot', 'p2']) lines = f.getvalue().split('\n') assert ('digraph G {' == lines[0]) assert (' "p2" -> "p1"' == lines[1]) assert ('}' == lines[2])
def test_args_error_if_config_unneeded(self): with self.assertRaises(InvalidArgumentsError): run(None, None, None, None, None, []) stderr = StringIO() main(None, stderr, None, None, None, [__name__]) assert(stderr.getvalue())
def test_invalid_path_error(self): with self.assertRaises(InvalidPathError): run(None, None, None, None, None, ['walk', 'foo']) stderr = StringIO() main(None, stderr, None, None, None, [__name__, 'walk', 'foo']) assert(stderr.getvalue())
def test_graph(self): f = StringIO() run(f, None, None, None, None, ['dot', 'p2']) lines = f.getvalue().split('\n') assert('digraph G {' == lines[0]) assert(' "p2" -> "p1"' == lines[1]) assert('}' == lines[2])
def test_args_error_if_config_unneeded(self): with self.assertRaises(InvalidArgumentsError): run(None, None, None, None, None, []) stderr = StringIO() main(None, stderr, None, None, None, [__name__]) assert (stderr.getvalue())
def test_target_with_dependencies(self): f = StringIO() run(f, None, None, None, None, ['walk', 'gr2']) r = TargetResolver(self._config) us = resolve(r, ['gr2']) assert (' '.join(u.name for u in us) + '\n' == f.getvalue())
def test_target_with_dependencies(self): f = StringIO() run(f, None, None, None, None, ['walk', 'gr2']) r = TargetResolver(self._config) us = resolve(r, ['gr2']) assert(' '.join(u.name for u in us) + '\n' == f.getvalue())
def test_generate_cmake(self): output1 = StringIO() run(output1, None, output1, None, ['cmake', 'bdemeta.json', 'p']) r = TargetResolver(self._config) p = resolve(r, 'p') output2 = StringIO() generate(p, output2) assert(output1.getvalue() == output2.getvalue())
def test_generate_cmake(self): output = StringIO() f1 = {} w1 = get_filestore_writer(f1) run(output, None, w1, None, None, ['cmake', 'p']) r = TargetResolver(self._config) p = resolve(r, 'p') f2 = {} w2 = get_filestore_writer(f2) generate(p, w2) assert (f1.keys() == f2.keys()) for k in f1: assert (f1[k].getvalue() == f2[k].getvalue())
def test_generate_cmake(self): output = StringIO() f1 = {} w1 = get_filestore_writer(f1) run(output, None, w1, None, None, ['cmake', 'p']) r = TargetResolver(self._config) p = resolve(r, 'p') f2 = {} w2 = get_filestore_writer(f2) generate(p, w2) assert(f1.keys() == f2.keys()) for k in f1: assert(f1[k].getvalue() == f2[k].getvalue())
def test_no_root_error(self): with self.assertRaises(InvalidPathError) as e: run(None, None, None, None, None, ['walk']) assert (P('r') == e.exception.args[0])
def test_unknown_mode_error(self): with self.assertRaises(InvalidArgumentsError) as e: run(None, None, None, None, None, ['foo']) assert ('Unknown mode \'{}\''.format('foo') == e.exception.args[0])
def test_unknown_mode_error(self): with self.assertRaises(InvalidArgumentsError) as e: run(None, None, None, None, None, ['foo']) assert('Unknown mode \'{}\''.format('foo') == e.exception.args[0])
def test_no_root_error(self): with self.assertRaises(InvalidPathError) as e: run(None, None, None, None, None, ['walk']) assert(P('r') == e.exception.args[0])
def test_no_mode_error(self): with self.assertRaises(InvalidArgumentsError) as e: run(None, None, None, None, None, []) assert ('No mode specified' == e.exception.args[0])
def test_no_config_error(self): with self.assertRaises(InvalidArgumentsError) as e: run(None, None, None, None, ['walk']) assert('No config specified' == e.exception.args[0])
def test_no_mode_error(self): with self.assertRaises(InvalidArgumentsError) as e: run(None, None, None, None, None, []) assert('No mode specified' == e.exception.args[0])