Skip to content

Commit

Permalink
test update
Browse files Browse the repository at this point in the history
  • Loading branch information
aakropotkin committed Dec 31, 2023
1 parent 0ec5a23 commit c66a2d9
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions src/sh-scripts/ccjs/tests/ccjs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,77 @@ teardown() {
}


# ---------------------------------------------------------------------------- #

# bats test_tags=ccjs:add,inline,multiple
@test "'ccjs add' multiple times appends file" {
refute "$TEST" -f compile_commands.json;
run "$CCJS" add -i src/main.cc -- -Iinclude -Wall;
assert_success;

run "$JQ" -r 'length' compile_commands.json;
assert_success;
assert_output '1';

run "$CCJS" add -i src/helper.cc -- -Iinclude -Wall;
assert_success;

run "$JQ" -r 'length' compile_commands.json;
assert_success;
assert_output '2';
}


# ---------------------------------------------------------------------------- #

# bats test_tags=ccjs:add,inline,multiple
@test "'ccjs add' updates existing file" {
refute "$TEST" -f compile_commands.json;
run "$CCJS" add -i src/main.cc -- -Iinclude -Wall;
assert_success;

run "$JQ" -r 'length' compile_commands.json;
assert_success;
assert_output '1';

run "$JQ" -r '.[0].arguments|length' compile_commands.json;
assert_success;
assert_output '2';

run "$JQ" -r '.[0].arguments[0]' compile_commands.json;
assert_success;
assert_output '-Iinclude';

run "$JQ" -r '.[0].arguments[1]' compile_commands.json;
assert_success;
assert_output '-Wall';

# Update the entry
run "$CCJS" add -i src/main.cc -- -I../include -Wall -Werror;
assert_success;

run "$JQ" -r 'length' compile_commands.json;
assert_success;
assert_output '1';

run "$JQ" -r '.[0].arguments|length' compile_commands.json;
assert_success;
assert_output '3';

run "$JQ" -r '.[0].arguments[0]' compile_commands.json;
assert_success;
assert_output '-I../include';

run "$JQ" -r '.[0].arguments[1]' compile_commands.json;
assert_success;
assert_output '-Wall';

run "$JQ" -r '.[0].arguments[2]' compile_commands.json;
assert_success;
assert_output '-Werror';
}


# ---------------------------------------------------------------------------- #
#
#
Expand Down

0 comments on commit c66a2d9

Please sign in to comment.