File size: 3,674 Bytes
559318d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
set -uxo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd /workspace
git config --global --add safe.directory /workspace
mkdir -p /logs/verifier
git checkout 72eb9a44f3986b54cf0692efc7cd7a0fdc65919f -- test/test_valid.py || true
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
diff --git a/test/test_valid.py b/test/test_valid.py
index 7163234..2685bc1 100644
--- a/test/test_valid.py
+++ b/test/test_valid.py
@@ -306,6 +306,15 @@ class FilenameTest(unittest.TestCase):
         with self.assertRaises(confit.ConfigTemplateError):
             config['foo'].get(confit.Filename(relative_to='bar'))
 
+    def test_filename_relative_to_sibling_can_use_default(self):
+        config = _root({'bar': 'baz'})
+        valid = config.get({
+            'foo': confit.Filename(default='/dev/null'),
+            'bar': confit.Filename(relative_to='foo')
+        })
+        self.assertEqual(valid.foo, os.path.realpath('/dev/null'))
+        self.assertEqual(valid.bar, os.path.realpath('/dev/null/baz'))
+
     def test_filename_relative_to_sibling_needs_template(self):
         config = _root({'foo': '/', 'bar': 'baz'})
         with self.assertRaises(confit.ConfigTemplateError):
@@ -313,6 +322,22 @@ class FilenameTest(unittest.TestCase):
                 'bar': confit.Filename(relative_to='foo')
             })
 
+    def test_filename_relative_to_non_filename(self):
+        config = _root({'foo': 0, 'bar': 'baz'})
+        with self.assertRaises(confit.ConfigTemplateError):
+            config.get({
+                'foo': confit.Integer(),
+                'bar': confit.Filename(relative_to='foo')
+            })
+
+    def test_filename_relative_to_non_filename_using_default(self):
+        config = _root({'bar': 'baz'})
+        with self.assertRaises(confit.ConfigTemplateError):
+            config.get({
+                'foo': confit.Integer(0),
+                'bar': confit.Filename(relative_to='foo')
+            })
+
     def test_filename_with_non_file_source(self):
         config = _root({'foo': 'foo/bar'})
         valid = config['foo'].get(confit.Filename())
@@ -340,6 +365,16 @@ class FilenameTest(unittest.TestCase):
         with self.assertRaises(confit.ConfigTypeError):
             config['foo'].get(confit.Filename())
 
+    def test_filename_required(self):
+        config = _root({})
+        with self.assertRaises(confit.NotFoundError):
+            config['foo'].get(confit.Filename())
+
+    def test_filename_default_is_never_wrong(self):
+        config = _root({})
+        valid = config['foo'].get(confit.Filename(default=None))
+        self.assertEqual(valid, None)
+
 
 class BaseTemplateTest(unittest.TestCase):
     def test_base_template_accepts_any_value(self):

EOF_R2E_TEST_PATCH
R2E_APPLY_RC=$?
if [ "$R2E_APPLY_RC" -ne 0 ]; then
  echo "0.000000" > /logs/verifier/reward.txt
  printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
  echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
  exit 0
fi
( python -m pytest -v test/test_valid.py ) > /logs/verifier/test_output.log 2>&1
TEST_EXIT_CODE=$?
cat /logs/verifier/test_output.log
python3 "$SCRIPT_DIR/verifier.py" --log /logs/verifier/test_output.log --f2p "$SCRIPT_DIR/f2p.json" --p2p "$SCRIPT_DIR/p2p.json" --test-cmds 'python -m pytest -v test/test_valid.py' --exit-code "$TEST_EXIT_CODE" --out-dir /logs/verifier || { [ "$TEST_EXIT_CODE" -eq 0 ] && echo "1.0" > /logs/verifier/reward.txt || echo "0.0" > /logs/verifier/reward.txt; }
git checkout 72eb9a44f3986b54cf0692efc7cd7a0fdc65919f -- test/test_valid.py || true
exit 0