| 183 | } |
| 184 | |
| 185 | uint64_t BytecodeTester::generic_test(const Vector<String> &p_paths, int ver_major_hint, int ver_minor_hint, bool include_dev, bool print_log_on_fail) { |
| 186 | int detected_bytecode_version = get_bytecode_version(p_paths); |
| 187 | ERR_FAIL_COND_V_MSG(detected_bytecode_version == -1, {}, "Inconsistent byecode versions across files!!!"); |
| 188 | ERR_FAIL_COND_V_MSG(detected_bytecode_version <= 0, {}, "Could not read bytecode version from files."); |
| 189 | |
| 190 | Vector<Ref<GDScriptDecomp>> decomp_versions = BytecodeTester::get_possible_decomps(p_paths, include_dev); |
| 191 | if (decomp_versions.size() == 1) { |
| 192 | // easy |
| 193 | return decomp_versions[0]->get_bytecode_rev(); |
| 194 | } |
| 195 | if (decomp_versions.size() == 0) { |
| 196 | if (!include_dev) { |
| 197 | // try again with the dev versions |
| 198 | return generic_test(p_paths, ver_major_hint, ver_minor_hint, true, print_log_on_fail); |
| 199 | } |
| 200 | // else fail |
| 201 | if (print_log_on_fail) { |
| 202 | // run the tests with print_verbose = true to put out a decent error log of what happened. |
| 203 | BytecodeTester::get_possible_decomps(p_paths, include_dev, true); |
| 204 | } |
| 205 | ERR_FAIL_V_MSG(0, "Failed to detect GDScript revision for bytecode version " + vformat("%d", detected_bytecode_version) + ", engine version " + vformat("%d.%d", ver_major_hint, ver_minor_hint) + ", please report this issue on GitHub."); |
| 206 | } |
| 207 | |
| 208 | // otherwise... |
| 209 | auto get_candidate_string = [&](const Ref<GDScriptDecomp> &decomp) -> String { |
| 210 | return vformat("%s (%07x)", decomp->get_engine_version().utf8().get_data(), decomp->get_bytecode_rev()); |
| 211 | }; |
| 212 | auto get_candidates_string = [&](const Vector<Ref<GDScriptDecomp>> &decomps) -> String { |
| 213 | String candidates_str; |
| 214 | for (int i = 0; i < decomps.size(); i++) { |
| 215 | candidates_str += get_candidate_string(decomps[i]); |
| 216 | if (i < decomps.size() - 1) { |
| 217 | candidates_str += ", "; |
| 218 | } |
| 219 | } |
| 220 | return candidates_str; |
| 221 | }; |
| 222 | auto candidates = BytecodeTester::filter_decomps(decomp_versions, ver_major_hint, ver_minor_hint); |
| 223 | |
| 224 | if (candidates.size() == 1) { |
| 225 | if (print_log_on_fail) { |
| 226 | print_line("Multiple passing candidates for bytecode version " + vformat("%d", detected_bytecode_version) + ":\n" + get_candidates_string(decomp_versions) + "\nChoosing only one that matches engine version: " + get_candidate_string(candidates[0]) + "."); |
| 227 | } |
| 228 | return candidates[0]->get_bytecode_rev(); |
| 229 | } |
| 230 | ERR_FAIL_V_MSG(0, "Failed to detect GDScript revision for bytecode version " + vformat("%d", detected_bytecode_version) + ", engine version " + vformat("%d.%d", ver_major_hint, ver_minor_hint) + ", candidates: " + get_candidates_string(decomp_versions) + "."); |
| 231 | // TODO: Smarter handling for this |
| 232 | } |
| 233 | |
| 234 | uint64_t BytecodeTester::test_files_2_1(const Vector<String> &p_paths) { |
| 235 | uint64_t rev = 0; |
nothing calls this directly
no test coverage detected