def test_commandlineArgs_machine_missingRequired(self, mock_stderr): """Test _commandline_args with --machine, with a missing required argument """ expected_re = r"--compiler must be provided if --rebuild is not set" with self.assertRaises(SystemExit): _ = _commandline_args( args_to_parse=['build/directory', '--machine', 'mymachine']) self.assertRegex(mock_stderr.getvalue(), expected_re)
def test_commandlineArgs_machine_valid(self): """Test _commandline_args with --machine, with a valid argument list (all required things present) """ # pylint: disable=no-self-use _ = _commandline_args(args_to_parse=[ 'build/directory', '--machine', 'mymachine', '--compiler', 'intel' ])
def test_commandlineArgs_rebuild_invalid4(self, mock_stderr): """Test _commandline_args with --rebuild, with an argument that is invalid with this option This tests an argument that is optional for new non-rebuild that isn't None """ expected_re = r"--no-build cannot be provided if --rebuild is set" with self.assertRaises(SystemExit): _ = _commandline_args( args_to_parse=['build/directory', '--rebuild', '--no-build']) self.assertRegex(mock_stderr.getvalue(), expected_re)
def test_commandlineArgs_rebuild_invalid2(self, mock_stderr): """Test _commandline_args with --rebuild, with an argument that is invalid with this option This tests an argument that is required for new machines, without a dash """ expected_re = r"--os cannot be provided if --rebuild is set" with self.assertRaises(SystemExit): _ = _commandline_args(args_to_parse=[ 'build/directory', '--rebuild', '--os', 'linux' ]) self.assertRegex(mock_stderr.getvalue(), expected_re)
def test_commandlineArgs_noRebuild_invalidNeedToDictatePnetcdf( self, mock_stderr): """Test _commandline_args without --rebuild or --machine: invalid b/c nothing specified for pnetcdf""" expected_re = r"For a user-defined machine, need to specify either --no-pnetcdf or --pnetcdf-path" with self.assertRaises(SystemExit): _ = _commandline_args(args_to_parse=[ 'build/directory', '--os', 'linux', '--compiler', 'intel', '--netcdf-path', '/path/to/netcdf', '--esmf-mkfile-path', '/path/to/esmf/lib/esmf.mk', '--max-mpitasks-per-node', '16' ]) self.assertRegex(mock_stderr.getvalue(), expected_re)
def test_commandlineArgs_noRebuild_valid(self): """Test _commandline_args without --rebuild or --machine, with a valid argument list (all required things present) """ # pylint: disable=no-self-use _ = _commandline_args(args_to_parse=[ 'build/directory', '--os', 'linux', '--compiler', 'intel', '--netcdf-path', '/path/to/netcdf', '--esmf-mkfile-path', '/path/to/esmf/lib/esmf.mk', '--max-mpitasks-per-node', '16', '--no-pnetcdf' ])
def test_commandlineArgs_machine_illegalArg2(self, mock_stderr): """Test _commandline_args with --rebuild, with an argument that is illegal with this option This tests an argument that is optional for new machines """ expected_re = r"--gmake cannot be provided if --machine is set" with self.assertRaises(SystemExit): _ = _commandline_args(args_to_parse=[ 'build/directory', '--machine', 'mymachine', '--compiler', 'intel', '--gmake', 'mymake' ]) self.assertRegex(mock_stderr.getvalue(), expected_re)
def test_commandlineArgs_noRebuild_invalidConflictingPnetcdf( self, mock_stderr): """Test _commandline_args without --rebuild or --machine: invalid b/c of conflicting specifications for pnetcdf""" expected_re = r"--no-pnetcdf cannot be given if you set --pnetcdf-path" with self.assertRaises(SystemExit): _ = _commandline_args(args_to_parse=[ 'build/directory', '--os', 'linux', '--compiler', 'intel', '--netcdf-path', '/path/to/netcdf', '--esmf-mkfile-path', '/path/to/esmf/lib/esmf.mk', '--max-mpitasks-per-node', '16', '--no-pnetcdf', '--pnetcdf-path', '/path/to/pnetcdf' ]) self.assertRegex(mock_stderr.getvalue(), expected_re)
def test_commandlineArgs_noRebuild_invalid2(self, mock_stderr): """Test _commandline_args without --rebuild or --machine, with a missing required argument This tests an argument in the new-machine-required list """ expected_re = r"--os must be provided if neither --machine nor --rebuild are set" with self.assertRaises(SystemExit): _ = _commandline_args(args_to_parse=[ 'build/directory', '--compiler', 'intel', '--netcdf-path', '/path/to/netcdf', '--esmf-lib-path', '/path/to/esmf/lib', '--max-mpitasks-per-node', '16', '--no-pnetcdf' ]) self.assertRegex(mock_stderr.getvalue(), expected_re)
def test_commandlineArgs_rebuild_valid(self): """Test _commandline_args with --rebuild, with a valid argument list (no disallowed args)""" # pylint: disable=no-self-use _ = _commandline_args(args_to_parse=['build/directory', '--rebuild'])