+# Check for changes in Molecule tests
+if ! $(git diff HEAD^ HEAD --exit-code --quiet ansible/test); then
+ # If there are any changes in ansible/test area
+ MOLECULE_CHANGES=(`git diff HEAD^ HEAD --name-only ansible/test | grep -v "ansible/test/play-.*/"`)
+ if [ ${#MOLECULE_CHANGES[@]} -gt 0 ]; then
+ # If detected changes that affect all playbook tests - run all
+ run_molecule "${ALL_PLAYBOOKS[@]}"
+ # memorize already tested playbooks
+ TESTED_PLAYBOOKS=${ALL_PLAYBOOKS[@]}
+ else
+ # Changes only in ansible/test/play-* area - run tests only for changed playbook tests
+ PLAYBOOKS=(`git diff HEAD^ HEAD --name-only ansible/test | cut -f 1-3 -d "/" | sort -u`)
+ run_molecule "${PLAYBOOKS[@]}"
+ # memorize already tested playbooks
+ TESTED_PLAYBOOKS=${PLAYBOOKS[@]}
+ fi
+fi