diff --git a/bin/test_loop_claude_black_box.py b/bin/test_loop_claude_black_box.py index 17696ca3..c98d30d3 100644 --- a/bin/test_loop_claude_black_box.py +++ b/bin/test_loop_claude_black_box.py @@ -400,19 +400,21 @@ class Models(unittest.TestCase): self.assertEqual(json.loads(checkout.models_file().read_text()), {"other": "model-x", "proj": "custom-model"}) self.assertEqual(stat.S_IMODE(checkout.models_file().stat().st_mode), 0o640) - checkout.models_file().write_text(json.dumps({"other": "model-x"})) - checkout.models_file().parent.chmod(0o500) - self.addCleanup(checkout.models_file().parent.chmod, 0o700) - run = checkout.run([worker()], terminal_input="custom-model\n") - self.assertEqual((run.code, run.calls), (1, [])) - self.assertIn(f"could not save the model in {checkout.models_file()}: Permission denied", run.stderr) - - checkout.models_file().parent.chmod(0o700) checkout.models_file().write_text("[]") run = checkout.run([worker()]) self.assertEqual((run.code, run.calls), (1, [])) self.assertIn(f"could not read {checkout.models_file()}", run.stderr) + @unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory") + def test_exits_1_when_the_models_file_cannot_be_written(self): + checkout = Checkout(self) + del checkout.env["LOOP_CLAUDE_JUDGE_MODEL"], checkout.env["LOOP_CLAUDE_WORKER_MODEL"] + checkout.models_file().parent.mkdir(parents=True, mode=0o500) + self.addCleanup(checkout.models_file().parent.chmod, 0o700) + run = checkout.run([worker()], terminal_input="custom-model\n") + self.assertEqual((run.code, run.calls), (1, [])) + self.assertIn(f"could not save the model in {checkout.models_file()}: Permission denied", run.stderr) + class Reload(unittest.TestCase): def test_an_edit_takes_effect_at_the_next_cycle_boundary_once_it_answers_help(self):