|
38 | 38 | mv rescript.json.bak rescript.json |
39 | 39 |
|
40 | 40 | success "experimental-features emits -enable-experimental twice as string list" |
| 41 | + |
| 42 | +bold "Test: build surfaces experimental-features list parse error" |
| 43 | + |
| 44 | +cp rescript.json rescript.json.bak |
| 45 | + |
| 46 | +node -e ' |
| 47 | +const fs = require("fs"); |
| 48 | +const j = JSON.parse(fs.readFileSync("rescript.json", "utf8")); |
| 49 | +j["experimental-features"] = ["LetUnwrap"]; |
| 50 | +fs.writeFileSync("rescript.json", JSON.stringify(j, null, 2)); |
| 51 | +' |
| 52 | + |
| 53 | +out=$(rewatch build 2>&1) |
| 54 | +status=$? |
| 55 | + |
| 56 | +mv rescript.json.bak rescript.json |
| 57 | +rm -f lib/rescript.lock |
| 58 | + |
| 59 | +if [ $status -eq 0 ]; then |
| 60 | + error "Expected build to fail for experimental-features list input" |
| 61 | + echo "$out" |
| 62 | + exit 1 |
| 63 | +fi |
| 64 | + |
| 65 | +echo "$out" | grep -q "Could not read rescript.json" |
| 66 | +if [ $? -ne 0 ]; then |
| 67 | + error "Missing rescript.json path context in build error" |
| 68 | + echo "$out" |
| 69 | + exit 1 |
| 70 | +fi |
| 71 | + |
| 72 | +echo "$out" | grep -qi "invalid type" |
| 73 | +if [ $? -ne 0 ]; then |
| 74 | + error "Missing detailed parse error in build output" |
| 75 | + echo "$out" |
| 76 | + exit 1 |
| 77 | +fi |
| 78 | + |
| 79 | +success "Experimental-features list produces detailed build error" |
| 80 | + |
| 81 | +bold "Test: watch reports invalid experimental-features without panicking" |
| 82 | + |
| 83 | +cp rescript.json rescript.json.bak |
| 84 | + |
| 85 | +node -e ' |
| 86 | +const fs = require("fs"); |
| 87 | +const cfg = JSON.parse(fs.readFileSync("rescript.json", "utf8")); |
| 88 | +cfg["experimental-features"] = ["LetUnwrap"]; |
| 89 | +fs.writeFileSync("rescript.json", JSON.stringify(cfg, null, 2)); |
| 90 | +' |
| 91 | + |
| 92 | +out=$(rewatch watch 2>&1) |
| 93 | +status=$? |
| 94 | + |
| 95 | +mv rescript.json.bak rescript.json |
| 96 | +rm -f lib/rescript.lock |
| 97 | + |
| 98 | +if [ $status -eq 0 ]; then |
| 99 | + error "Expected watch to fail for invalid experimental-features list" |
| 100 | + echo "$out" |
| 101 | + exit 1 |
| 102 | +fi |
| 103 | + |
| 104 | +echo "$out" | grep -q "Could not read rescript.json" |
| 105 | +if [ $? -ne 0 ]; then |
| 106 | + error "Missing rescript.json path context in watch error" |
| 107 | + echo "$out" |
| 108 | + exit 1 |
| 109 | +fi |
| 110 | + |
| 111 | +echo "$out" | grep -qi "invalid type" |
| 112 | +if [ $? -ne 0 ]; then |
| 113 | + error "Missing detailed parse error for experimental-features list" |
| 114 | + echo "$out" |
| 115 | + exit 1 |
| 116 | +fi |
| 117 | + |
| 118 | +echo "$out" | grep -q "panicked" |
| 119 | +if [ $? -eq 0 ]; then |
| 120 | + error "Watcher should not panic when config is invalid" |
| 121 | + echo "$out" |
| 122 | + exit 1 |
| 123 | +fi |
| 124 | + |
| 125 | +success "Invalid experimental-features list handled without panic" |
0 commit comments