Skip to content

Commit cab5d07

Browse files
committed
Merge branch 'asar_19'
2 parents f2793fe + 3948d6f commit cab5d07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+401
-378
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ These two characters should precede each test line, so that Asar sees them as co
5353
* 2 hex digits - a byte for it to check for
5454
* You can specify more than one, like in the examples below, and it will automatically increment the offset.
5555
* A line starting with `+` tells the testing app to patch the SMW ROM instead of creating a new ROM
56-
* `errEXXXX` and `warnWXXXX` (where `XXXX` is an ID number) means that the test is expected to throw that specific error or warning while patching. The test will succeed only if the number and order of errors and warnings thrown exactly matches what's specified here. Be wary that Asar uses multiple passes and throws errors and warnings across multiple of them. This can make the actual order in which errors and warnings are thrown a bit unintuitive.
56+
* `errE{name}` and `warnW{name}` (where `{name}` is the name of an error or warning) means that the test is expected to throw that specific error or warning while patching. The test will succeed only if the number and order of errors and warnings thrown exactly matches what's specified here. Be wary that Asar uses multiple passes and throws errors and warnings across multiple of them. This can make the actual order in which errors and warnings are thrown a bit unintuitive.
5757

5858
In addition to the format mentioned above, it's also possible to check for user prints a patch is expected to output (by `print`, `error`, `warn` or `assert` commands). This is done by starting the line with one of the following sequences:
5959
```
@@ -75,17 +75,17 @@ This line tests that `22`, `20`, `80` and `90` were written to the ROM offset `0
7575
;`007606 22 20 80 90
7676
```
7777

78-
This line tests that assembling the patch throws error `5117` twice and warning `1030` once.
78+
This line tests that assembling the patch throws error `Eunknown_command` twice and warning `Wfeature_deprecated` once.
7979
```
80-
;`errE5117
81-
;`errE5117
82-
;`warnW1030
80+
;`errEunknown_command
81+
;`errEunknown_command
82+
;`warnWfeature_deprecated
8383
```
8484

85-
This line tests that the byte `FF` was written to the start of the ROM, that the string `This is a print.` was printed and that the string `This is a user error.` was output via the error command (which itself also causes error `E5159`to be thrown once).
85+
This line tests that the byte `FF` was written to the start of the ROM, that the string `This is a print.` was printed and that the string `This is a user error.` was output via the error command (which itself also causes error `Eerror_command` to be thrown once).
8686
```
8787
;`FF
8888
;P>This is a print.
8989
;E>This is a user error.
90-
;`errE5159
90+
;`errEerror_command
9191
```

docs/changelog/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ <h3>Contributors:</h3>
4747
<li>randomdude999</li>
4848
</ul>
4949

50+
<h3>Notes:</h3>
51+
<ul>
52+
<li>The primary purpose of this release is to be a stepping stone towards Asar 2.0. For this purpose, a lot of features have been deprecated and will now throw warnings. Please fix any of those warnings you come across in your patches to assure they will still assemble in Asar 2.0.</li>
53+
</ul></div>
54+
5055
<h3>New features:</h3>
5156
<ul>
5257
<li>The Asar test suite can now verify user-printable strings. (RPG Hacker)</li>
@@ -64,6 +69,11 @@ <h3>Bug fixes:</h3>
6469
<li><code>'''</code> and <code>';'</code> are now valid can now be used without causing errors. (randomdude999, RPG Hacker)</li>
6570
</ul></div>
6671

72+
<h3>Deprecated features:</h3>
73+
<ul>
74+
<li>Warning and error IDs: Asar now uses named warnings and errors. (p4plus2, RPG Hacker)</li>
75+
</ul></div>
76+
6777
<hr />
6878

6979
<div><h2>v1.81</h2>

src/asar-tests/test.cpp

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,8 @@ int main(int argc, char * argv[])
534534

535535
int numiter = 1;
536536

537-
std::vector<int> expected_errors;
538-
std::vector<int> expected_warnings;
537+
std::vector<std::string> expected_errors;
538+
std::vector<std::string> expected_warnings;
539539
std::vector<std::string> expected_prints;
540540
std::vector<std::string> expected_error_prints;
541541
std::vector<std::string> expected_warn_prints;
@@ -604,30 +604,16 @@ int main(int argc, char * argv[])
604604
if (strncmp(cur_word.c_str(), token, strlen(token)) == 0)
605605
{
606606
const char* idstr = cur_word.c_str() + strlen(token);
607-
char* endpos = nullptr;
608-
long int id = strtol(idstr, &endpos, 10);
609607

610-
if (endpos == nullptr || *endpos != '\0')
611-
{
612-
dief("Error: Invalid %s declaration!\n", token);
613-
}
614-
615-
expected_errors.push_back((int)id);
608+
expected_errors.push_back(idstr-1);
616609
}
617610

618611
token = "warnW";
619612
if (strncmp(cur_word.c_str(), token, strlen(token)) == 0)
620613
{
621614
const char* idstr = cur_word.c_str() + strlen(token);
622-
char* endpos = nullptr;
623-
long int id = strtol(idstr, &endpos, 10);
624-
625-
if (endpos == nullptr || *endpos != '\0')
626-
{
627-
dief("Error: Invalid %s declaration!\n", token);
628-
}
629615

630-
expected_warnings.push_back((int)id);
616+
expected_warnings.push_back(idstr-1);
631617
}
632618

633619
if (pos > len) len = pos;
@@ -824,8 +810,8 @@ int main(int argc, char * argv[])
824810
FILE * out = nullptr;
825811
#endif
826812

827-
std::vector<int> actual_errors;
828-
std::vector<int> actual_warnings;
813+
std::vector<std::string> actual_errors;
814+
std::vector<std::string> actual_warnings;
829815
std::vector<std::string> actual_prints;
830816
std::vector<std::string> actual_error_prints;
831817
std::vector<std::string> actual_warn_prints;
@@ -851,20 +837,20 @@ int main(int argc, char * argv[])
851837
size_t found = log_line.find(token);
852838
if (found != std::string::npos)
853839
{
854-
char* endpos = nullptr;
855-
long int num = strtol(log_line.c_str() + found + strlen(token), &endpos, 10);
840+
size_t found_end = log_line.find(')', found + 1);
856841

857-
if (endpos == nullptr || *endpos != ')')
842+
if (found_end == std::string::npos)
858843
{
859-
dief("Error: Failed parsing error code from Asar output!\n");
844+
dief("Error: Failed parsing error name from Asar output!\n");
860845
}
861846

862-
actual_errors.push_back(num);
847+
size_t start_pos = found + strlen(token) - 1;
848+
actual_errors.push_back(log_line.substr(start_pos, found_end - start_pos));
863849

864850
// RPG Hacker: Check if it's the error command. If so, we also need to add a print as well.
865851
{
866852
std::string command_token = ": error command: ";
867-
std::string remainder = endpos;
853+
std::string remainder = log_line.substr(found_end+1);
868854
size_t command_found = remainder.find(command_token);
869855

870856
if (command_found != std::string::npos)
@@ -877,7 +863,7 @@ int main(int argc, char * argv[])
877863
{
878864
std::string command_token_1 = ": Assertion failed: ";
879865
std::string command_token_2 = " [assert ";
880-
std::string remainder = endpos;
866+
std::string remainder = log_line.substr(found_end + 1);
881867
size_t command_found_1 = remainder.find(command_token_1);
882868
size_t command_found_2 = remainder.find(command_token_2);
883869

@@ -895,20 +881,20 @@ int main(int argc, char * argv[])
895881
found = log_line.find(token);
896882
if (found != std::string::npos)
897883
{
898-
char* endpos = nullptr;
899-
long int num = strtol(log_line.c_str() + found + strlen(token), &endpos, 10);
884+
size_t found_end = log_line.find(')', found + 1);
900885

901-
if (endpos == nullptr || *endpos != ')')
886+
if (found_end == std::string::npos)
902887
{
903888
dief("Error: Failed parsing warning code from Asar output!\n");
904889
}
905890

906-
actual_warnings.push_back(num);
891+
size_t start_pos = found + strlen(token) - 1;
892+
actual_warnings.push_back(log_line.substr(start_pos, found_end - start_pos));
907893

908894
// RPG Hacker: Check if it's the warn command. If so, we also need to add a print as well.
909895
{
910896
std::string command_token = ": warn command: ";
911-
std::string remainder = endpos;
897+
std::string remainder = log_line.substr(found_end + 1);
912898
size_t command_found = remainder.find(command_token);
913899

914900
if (command_found != std::string::npos)
@@ -1000,28 +986,28 @@ int main(int argc, char * argv[])
1000986
printf("\nExpected errors: ");
1001987
for (auto it = expected_errors.begin(); it != expected_errors.end(); ++it)
1002988
{
1003-
printf("%sE%d", (it != expected_errors.begin() ? "," : ""), *it);
989+
printf("%s%s", (it != expected_errors.begin() ? "," : ""), it->c_str());
1004990
}
1005991
printf("\n");
1006992

1007993
printf("Actual errors: ");
1008994
for (auto it = actual_errors.begin(); it != actual_errors.end(); ++it)
1009995
{
1010-
printf("%sE%d", (it != actual_errors.begin() ? "," : ""), *it);
996+
printf("%s%s", (it != actual_errors.begin() ? "," : ""), it->c_str());
1011997
}
1012998
printf("\n");
1013999

10141000
printf("\nExpected warnings: ");
10151001
for (auto it = expected_warnings.begin(); it != expected_warnings.end(); ++it)
10161002
{
1017-
printf("%sW%d", (it != expected_warnings.begin() ? "," : ""), *it);
1003+
printf("%s%s", (it != expected_warnings.begin() ? "," : ""), it->c_str());
10181004
}
10191005
printf("\n");
10201006

10211007
printf("Actual warnings: ");
10221008
for (auto it = actual_warnings.begin(); it != actual_warnings.end(); ++it)
10231009
{
1024-
printf("%sW%d", (it != actual_warnings.begin() ? "," : ""), *it);
1010+
printf("%s%s", (it != actual_warnings.begin() ? "," : ""), it->c_str());
10251011
}
10261012
printf("\n");
10271013

@@ -1068,7 +1054,7 @@ int main(int argc, char * argv[])
10681054
fclose(rom);
10691055
#endif
10701056
bool fail = false;
1071-
for (int i = 0;i < min(len, truelen);i++)
1057+
for (int i = 0;i < min(len, truelen); i++)
10721058
{
10731059
if (truerom[i] != expectedrom[i] && !(i >= 0x07FDC && i <= 0x07FDF && (expectedrom[i] == 0x00 || expectedrom[i] == smwrom[i])))
10741060
{

0 commit comments

Comments
 (0)