zar icon indicating copy to clipboard operation
zar copied to clipboard

Create test framework for testing

Open moosichu opened this issue 4 years ago • 6 comments

As of writing we already have some commands outputting the correct values based on the test data, eg:

$ zig build run -- t test/data/test1/output_llvm-ar_gnu.a 
input1.txt
input2.txt
$ zig build run -- t test/data/test2/output_llvm-ar_gnu.a 
input1.txt
input2.txt
input3_that_is_also_a_much_longer_file_name.txt
input4_that_is_also_a_much_longer_file_name.txt

As we add features that replicate the functionality of llvm-ar - it would be good to have a set of tests we can use to both test for:

  • regression
  • features to be implemented

It should be quite simple. For each command using some of the example files to both parse/produce archives and then test those against what was produced by llvm-ar for the same inputs.

Was we only of the t command working (in a very limited way) so far - for the purposes of this issue focusing on that could be a good place to start.

Using what is generated for #1.

moosichu avatar Sep 26 '21 17:09 moosichu

I am happy to look into this! I will have a look how llvm-ar implements tests and try to recreate that

ceckertz avatar Sep 27 '21 12:09 ceckertz

I wouldn't start with that - look at how tests are normally done for zig projects. In terms of existing ar implementations, for now I would recommend ignoring them (or only treating them as a black box). The goal isn't to make a copy of an existing implementation but write something new in zig that's as simple as possible but does the same job.

moosichu avatar Sep 27 '21 12:09 moosichu

But otherwise so feel free to work on this! I'm looking forward to seeing what you come up with. This is also related to #5.

moosichu avatar Sep 27 '21 12:09 moosichu

Ok makes sense! Thanks :)

ceckertz avatar Sep 27 '21 13:09 ceckertz

I've made a little start on this for the most simple case: https://github.com/moosichu/zar/commit/9b06af00f57bc6833d44af729a91d1a948954d3d

(BSD tests are currently commented out because they aren't working - that needs investigating).

However this is very bare-bones, so feedback & fleshing this out to cover the other operations we support as well would be great.

moosichu avatar Sep 30 '21 19:09 moosichu

I'll look into it :)

ceckertz avatar Oct 05 '21 08:10 ceckertz