<commit_before>#!/bin/bash

set -e
set -o pipefail

name=$(basename $0 .sh)
result=$(mktemp -t ${name}.out.XXXXXX)
stderr=$(mktemp -t ${name}.out.XXXXXX)

$OSCAP xccdf eval --results $result $srcdir/${name}.xccdf.xml 2> $stderr

echo "Stderr file = $stderr"
echo "Result file = $result"
[ -s $stderr ] && rm -rf $stderr

$OSCAP xccdf validate-xml $result

[ "$(xpath $result 'count(//refine-rule[@weight])')" == "0" ]
[ "$(xpath $result 'count(//refine-rule[not(@weight)])')" == "1" ]

rm -rf $result<commit_msg>tests: trac#186: assert that none check is used when no profile is selected.<commit_after>#!/bin/bash

set -e
set -o pipefail

name=$(basename $0 .sh)
result=$(mktemp -t ${name}.out.XXXXXX)
stderr=$(mktemp -t ${name}.out.XXXXXX)

$OSCAP xccdf eval --results $result $srcdir/${name}.xccdf.xml 2> $stderr

echo "Stderr file = $stderr"
echo "Result file = $result"
[ -s $stderr ] && rm -rf $stderr

$OSCAP xccdf validate-xml $result

[ "$(xpath $result 'count(//refine-rule[@weight])')" == "0" ]
assert_exists_once() { [ "$(xpath $result 'count('$1')')" == "1" ]; }
assert_exists_once '//refine-rule[not(@weight)]'
assert_exists_once '//rule-result'
assert_exists_once '//rule-result/result'
assert_exists_once '//rule-result/result[text()="notchecked"]'
assert_exists_once '//rule-result[not(check)]'

rm -rf $result
{'fraction_non_alphanumeric': 0.20889894419306185, 'fraction_numerical': 0.00904977375565611, 'mean_word_length': 4.794759825327511, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5102212', 'n_tokens_mistral': 520, 'n_tokens_neox': 502, 'n_words': 124}