From d00ebe53975cc64ee569cf40ce8a9c18bcfc52d8 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Sat, 24 Sep 2022 13:04:52 -0400 Subject: [PATCH] tests: allow for a single file to be tested in the offline-tests at a time (#1907) A small quality of life increase that is more impactful since jak 2 has double the file count. I often use the offline-tests to find compiler errors / automatically resolve them when i am finalizing a file. As more and more files are completed this becomes increasingly more inefficient. When I know that only 1 file needs to be decompiled / compared / compiled, I'd prefer to have a feature like this. --- Taskfile.yml | 10 ++++++++++ test/offline/offline_test_main.cpp | 13 ++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 18eee72b22..cb2af92df1 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -110,6 +110,9 @@ tasks: offline-tests: cmds: - '{{.OFFLINETEST_BIN_RELEASE_DIR}}/offline-test --iso_data_path "./iso_data/{{.GAME}}" --game {{.GAME}}' + offline-test-file: + cmds: + - '{{.OFFLINETEST_BIN_RELEASE_DIR}}/offline-test --iso_data_path "./iso_data/{{.GAME}}" --game {{.GAME}} --file {{.FILE}}' update-ref-tests: cmds: - cmd: python ./scripts/tasks/default-file-or-folder.py --path failures @@ -117,6 +120,13 @@ tasks: ignore_error: true - python ./scripts/update_decomp_reference.py ./failures ./test/decompiler/reference/ --game {{.GAME}} - task: offline-tests + update-ref-file: + cmds: + - cmd: python ./scripts/tasks/default-file-or-folder.py --path failures + - cmd: '{{.OFFLINETEST_BIN_RELEASE_DIR}}/offline-test --iso_data_path "./iso_data/{{.GAME}}" --file {{.FILE}} --game {{.GAME}} --dump_current_output' + ignore_error: true + - python ./scripts/update_decomp_reference.py ./failures ./test/decompiler/reference/ --game {{.GAME}} + - task: offline-test-file # check-gsrc-file: # cmds: # - python ./scripts/check-gsrc-file.py --files "{{.FILES}}" diff --git a/test/offline/offline_test_main.cpp b/test/offline/offline_test_main.cpp index bffc6cbb8f..dd09a68d73 100644 --- a/test/offline/offline_test_main.cpp +++ b/test/offline/offline_test_main.cpp @@ -290,7 +290,8 @@ std::vector find_art_files(const std::string& game_name, } std::vector find_files(const std::string& game_name, - const std::vector& dgos) { + const std::vector& dgos, + const std::string& single_file) { std::vector result; auto base_dir = @@ -300,7 +301,9 @@ std::vector find_files(const std::string& game_name, for (const auto& path : ref_file_paths) { auto ref_name = path.filename().replace_extension().string(); ref_name.erase(ref_name.begin() + ref_name.find("_REF"), ref_name.end()); - ref_file_names[ref_name] = path; + if (single_file.empty() || ref_name == single_file) { + ref_file_names[ref_name] = path; + } } lg::info("Found {} reference files", ref_file_paths.size()); @@ -397,6 +400,7 @@ int main(int argc, char* argv[]) { std::string game_name; // Useful for testing in debug mode (dont have to wait for everything to finish) int max_files = -1; + std::string single_file = ""; CLI::App app{"OpenGOAL - Offline Reference Test Runner"}; app.add_option("--iso_data_path", iso_data_path, "The path to the folder with the ISO data files") @@ -408,6 +412,9 @@ int main(int argc, char* argv[]) { "files update script"); app.add_option("-m,--max_files", max_files, "Limit the amount of files ran in a single test, picks the first N"); + app.add_option("-f,--file", single_file, + "Limit the offline test routine to a single file to decompile/compile -- useful " + "when you are just iterating on a single file"); app.validate_positionals(); CLI11_PARSE(app, argc, argv); @@ -422,7 +429,7 @@ int main(int argc, char* argv[]) { } lg::info("Finding files..."); - auto files = find_files(game_name, config->dgos); + auto files = find_files(game_name, config->dgos, single_file); if (max_files > 0 && max_files < (int)files.size()) { files.erase(files.begin() + max_files, files.end()); }