nlsandler / writing-a-c-compiler-tests

Test cases for Writing a C Compiler
https://nostarch.com/writing-c-compiler
Other
172 stars 25 forks source link

Compiler "failing" even though it is returning 0 for the case #81

Closed SunilPaul174 closed 1 month ago

SunilPaul174 commented 1 month ago

I'm not sure if i have structured my driver wrong or something, but the program is failing tests even though when run individually, it is returning 0. Screenshot_20240923_091404 The tests failed are:

test_framework.basic.TestChapter1.test_valid/multi_digit
test_framework.basic.TestChapter1.test_valid/newlines
test_framework.basic.TestChapter1.test_valid/no_newlines
test_framework.basic.TestChapter1.test_valid/return_0
test_framework.basic.TestChapter1.test_valid/return_2
test_framework.basic.TestChapter1.test_valid/spaces
test_framework.basic.TestChapter1.test_valid/tabs
nlsandler commented 1 month ago

Thanks for reporting this! Could you please include the whole command you're using to invoke the test script?

SunilPaul174 commented 1 month ago

./test_compiler ./compiler --chapter 1 --stage codegen Where compiler is the rust binary i have copied target/release/<cratename> into the repository directory of these tests

SunilPaul174 commented 1 month ago

image information about the machine, if it's necessary

nlsandler commented 1 month ago

Thanks!

The test script invokes your compiler with the --codegen option first, before the source file name. Does your compiler driver expect --codegen to come last? That could the issue you're seeing.

SunilPaul174 commented 1 month ago

It does, i'll try restructuring it.

SunilPaul174 commented 1 month ago

Thank you! After some unrelated bug fixes to the compiler, putting the option for the compiler before the file works! image I'll be closing this issue now.

nlsandler commented 1 month ago

I'm glad you got this working! And thanks again for filing it - it pointed out a usability issue with the test script.

SunilPaul174 commented 1 month ago

No problem! Thank you for your hard work.