Closed Michael2109 closed 6 years ago
This should be reconsidered not only for testing pusposes as manually inputting all files to compile is not the best thing. Some wildcard support might help.
I've had a look into how javac
deals with this.
If the class has a main method it will then work out which other classes to compile.
This would have to be a new thing for us to add in though and until we get the symbol tables sorted it will be quite some work I imagine.
With the test .cobalt
files they will each contain main methods and not necessarily depend on each other. In this case I feel it makes sense just to loop through them all.
Do any other compilers have this feature?
Well, this might be possible by enforcing the filename to be a class name just like in Java. I don't know whether javac searches only in the current directory or if it traverses everything while looking for the imported classes to compile. For single package it seems that it is possible to use wildcards in javac too.
I imagine Java traverses all imported classes.
Can you specify whole packages with javac
? If javac
or other compilers allow compiling whole directories then I'm happy to.
I am not an expert, but I remember compiling one project using command javac *.java
which compiled everything in the current directory. Important thing to note is, that there was no package defined in compiled files.
Okay if there is then I'm happy to add it in.
So, I am still not sure how javac actually works, but I fell like using wildcard from shell could work nicely as shell would expand it beforer feeding to the compiler.
When looking it up I couldn't find a way javac just compiles a whole directory. That could work. As long as it works cross platform it would be good.
Currently in the integration tests we have to individually specify the path of the file and run the compiler. Then we check that the generated code is correct. Instead of having to specify this we could simplify it by compiling all cobalt files before running any tests. From there we can then test all code is generated properly. This requires less code to run the compiler as it is automatically run first. It leaves us to only execute the generated code and will save time and leaves us with less risk of typos. If any files don't compile correctly an error should be shown.,