diff options
Diffstat (limited to 'node_modules/node-sass/src/libsass/script')
11 files changed, 1048 insertions, 0 deletions
diff --git a/node_modules/node-sass/src/libsass/script/bootstrap b/node_modules/node-sass/src/libsass/script/bootstrap new file mode 100755 index 0000000..ab82fac --- /dev/null +++ b/node_modules/node-sass/src/libsass/script/bootstrap @@ -0,0 +1,13 @@ +#!/bin/bash + +script/branding + +: ${SASS_SPEC_PATH:="sass-spec"} +: ${SASS_SASSC_PATH:="sassc" } + +if [ ! -d $SASS_SPEC_PATH ]; then + git clone https://github.com/sass/sass-spec.git $SASS_SPEC_PATH +fi +if [ ! -d $SASS_SASSC_PATH ]; then + git clone https://github.com/sass/sassc.git $SASS_SASSC_PATH +fi diff --git a/node_modules/node-sass/src/libsass/script/branding b/node_modules/node-sass/src/libsass/script/branding new file mode 100755 index 0000000..cd8cb2a --- /dev/null +++ b/node_modules/node-sass/src/libsass/script/branding @@ -0,0 +1,10 @@ +#! /bin/bash + +echo " " +echo " _ ___ ____ ____ _ ____ ____ " +echo "| | |_ _| __ ) ___| / \ / ___/ ___| " +echo "| | | || _ \___ \ / _ \ \___ \___ \ " +echo "| |___ | || |_) |__) / ___ \ ___) |__) |" +echo "|_____|___|____/____/_/ \_\____/____/ " +echo " " + diff --git a/node_modules/node-sass/src/libsass/script/ci-build-libsass b/node_modules/node-sass/src/libsass/script/ci-build-libsass new file mode 100755 index 0000000..40ea22f --- /dev/null +++ b/node_modules/node-sass/src/libsass/script/ci-build-libsass @@ -0,0 +1,134 @@ +#!/bin/bash + +set -e + +script/bootstrap + +# export this path right here (was in script/spec before) +export SASS_LIBSASS_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../ && pwd )" + +# use some defaults if not running under travis ci +if [ "x$CONTINUOUS_INTEGRATION" == "x" ]; then export CONTINUOUS_INTEGRATION=true; fi +if [ "x$TRAVIS_BUILD_DIR" == "x" ]; then export TRAVIS_BUILD_DIR=$(pwd); fi +if [ "x$SASS_SASSC_PATH" == "x" ]; then export SASS_SASSC_PATH=$(pwd)/sassc; fi +if [ "x$SASS_SPEC_PATH" == "x" ]; then export SASS_SPEC_PATH=$(pwd)/sass-spec; fi + +# try to get the os name from uname (and filter via perl - probably not the most portable way?) +if [ "x$TRAVIS_OS_NAME" == "x" ]; then export TRAVIS_OS_NAME=`uname -s | perl -ne 'print lc \$1 if\(/^([a-zA-Z]+)/'\)`; fi + +if [ "x$COVERAGE" == "xyes" ]; then + COVERAGE_OPT="--enable-coverage" + export EXTRA_CFLAGS="-fprofile-arcs -ftest-coverage" + export EXTRA_CXXFLAGS="-fprofile-arcs -ftest-coverage" + if [ "$TRAVIS_OS_NAME" == "osx" ]; then + # osx doesn't seem to know gcov lib? + export EXTRA_LDFLAGS="--coverage" + else + export EXTRA_LDFLAGS="-lgcov --coverage" + fi +else + COVERAGE_OPT="--disable-coverage" +fi + +if [ "x$BUILD" == "xstatic" ]; then + SHARED_OPT="--disable-shared --enable-static" + MAKE_TARGET="static" +else + # Makefile of sassc wants to link to static + SHARED_OPT="--enable-shared --enable-static" + MAKE_TARGET="shared" +fi + +if [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then + MAKE_OPTS="$MAKE_OPTS -j1 V=1" +else + MAKE_OPTS="$MAKE_OPTS -j5 V=1" +fi + +if [ "x$PREFIX" == "x" ]; then + if [ "x$TRAVIS_BUILD_DIR" == "x" ]; then + PREFIX=$SASS_LIBSASS_PATH/build + else + PREFIX=$TRAVIS_BUILD_DIR/build + fi +fi + +# enable address sanitation +# https://en.wikipedia.org/wiki/AddressSanitizer +if [ "x$CC" == "xclang" ]; then + if [ "x$COVERAGE" != "xyes" ]; then + if [ "$TRAVIS_OS_NAME" == "linux" ]; then + export EXTRA_CFLAGS="$EXTRA_CFLAGS -fsanitize=address" + export EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -fsanitize=address" + export EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fsanitize=address" + fi + fi +fi + +echo SASS_LIBSASS_PATH: $SASS_LIBSASS_PATH +echo TRAVIS_BUILD_DIR: $TRAVIS_BUILD_DIR +echo SASS_SASSC_PATH: $SASS_SASSC_PATH +echo SASS_SPEC_PATH: $SASS_SPEC_PATH +echo INSTALL_LOCATION: $PREFIX + +if [ "x$AUTOTOOLS" == "xyes" ]; then + + echo -en 'travis_fold:start:configure\r' + autoreconf --force --install + ./configure --enable-tests $COVERAGE_OPT \ + --disable-silent-rules \ + --with-sassc-dir=$SASS_SASSC_PATH \ + --with-sass-spec-dir=$SASS_SPEC_PATH \ + --prefix=$PREFIX \ + ${SHARED_OPT} + echo -en 'travis_fold:end:configure\r' + + make $MAKE_OPTS clean + + # install to prefix directory + PREFIX="$PREFIX" make $MAKE_OPTS install + +else + + make $MAKE_OPTS clean + +fi + +# install to prefix directory +PREFIX="$PREFIX" make $MAKE_OPTS install + +ls -la $PREFIX/* + +echo successfully compiled libsass +echo AUTOTOOLS=$AUTOTOOLS COVERAGE=$COVERAGE BUILD=$BUILD + +if [ "$CONTINUOUS_INTEGRATION" == "true" ] && [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "x$TRAVIS_PULL_REQUEST" != "x" ] && + ([ "$TRAVIS_OS_NAME" == "linux" ] || [ "$TRAVIS_OS_NAME" == "osx" ] || [ "$TRAVIS_OS_NAME" == "cygwin" ]); +then + + echo "Fetching PR $TRAVIS_PULL_REQUEST" + + JSON=$(curl -L -sS https://api.github.com/repos/sass/libsass/pulls/$TRAVIS_PULL_REQUEST) + + if [[ $JSON =~ "API rate limit exceeded" ]]; + then + echo "Travis rate limit on github exceeded" + echo "Retrying via 'special purpose proxy'" + JSON=$(curl -L -sS https://github-api-reverse-proxy.herokuapp.com/repos/sass/libsass/pulls/$TRAVIS_PULL_REQUEST) + fi + + RE_SPEC_PR="sass\/sass-spec(#|\/pull\/)([0-9]+)" + + if [[ $JSON =~ $RE_SPEC_PR ]]; + then + SPEC_PR="${BASH_REMATCH[2]}" + echo "Fetching Sass Spec PR $SPEC_PR" + git -C sass-spec fetch -u origin pull/$SPEC_PR/head:ci-spec-pr-$SPEC_PR + git -C sass-spec checkout --force ci-spec-pr-$SPEC_PR + LD_LIBRARY_PATH="$PREFIX/lib/" make $MAKE_OPTS test_probe + else + LD_LIBRARY_PATH="$PREFIX/lib/" make $MAKE_OPTS test_probe + fi +else + LD_LIBRARY_PATH="$PREFIX/lib/" make $MAKE_OPTS test_probe +fi diff --git a/node_modules/node-sass/src/libsass/script/ci-build-plugin b/node_modules/node-sass/src/libsass/script/ci-build-plugin new file mode 100755 index 0000000..0dd67b9 --- /dev/null +++ b/node_modules/node-sass/src/libsass/script/ci-build-plugin @@ -0,0 +1,62 @@ +#!/bin/bash + +PLUGIN=$1 +RUBY_BIN=ruby +SASS_SPEC_PATH=sass-spec +SASSC_BIN=sassc/bin/sassc +SASS_SPEC_SPEC_DIR=plugins/libsass-${PLUGIN}/test + +if [ -e ./tester ] ; then + SASSC_BIN=./tester +fi + +if [ -d ./build/lib ] ; then + cp -a build/lib lib +fi + +if [ "x$1" == "x" ] ; then + echo "No plugin name given" + exit 1 +fi + +if [ "x$COVERAGE" == "0" ] ; then + unset COVERAGE +fi + +export EXTRA_CFLAGS="" +export EXTRA_CXXFLAGS="" +if [ "$TRAVIS_OS_NAME" == "osx" ]; then + # osx doesn't seem to know gcov lib? + export EXTRA_LDFLAGS="--coverage" +else + export EXTRA_LDFLAGS="-lgcov --coverage" +fi + +mkdir -p plugins +if [ ! -d plugins/libsass-${PLUGIN} ] ; then + git clone https://github.com/mgreter/libsass-${PLUGIN} plugins/libsass-${PLUGIN} +fi +if [ ! -d plugins/libsass-${PLUGIN}/build ] ; then + mkdir plugins/libsass-${PLUGIN}/build +fi +RETVAL=$?; if [ "$RETVAL" != "0" ]; then exit $RETVAL; fi + +cd plugins/libsass-${PLUGIN}/build +cmake -G "Unix Makefiles" -D LIBSASS_DIR="../../.." .. +RETVAL=$?; if [ "$RETVAL" != "0" ]; then exit $RETVAL; fi +make VERBOSE=1 -j2 +RETVAL=$?; if [ "$RETVAL" != "0" ]; then exit $RETVAL; fi +cd ../../.. + +# glob only works on paths relative to imports +if [ "x$PLUGIN" == "xglob" ]; then + ${SASSC_BIN} --plugin-path plugins/libsass-${PLUGIN}/build ${SASS_SPEC_SPEC_DIR}/basic/input.scss > ${SASS_SPEC_SPEC_DIR}/basic/result.css + ${SASSC_BIN} --plugin-path plugins/libsass-${PLUGIN}/build ${SASS_SPEC_SPEC_DIR}/basic/input.scss --sourcemap > /dev/null +else + cat ${SASS_SPEC_SPEC_DIR}/basic/input.scss | ${SASSC_BIN} --precision 5 --plugin-path plugins/libsass-${PLUGIN}/build -I ${SASS_SPEC_SPEC_DIR}/basic > ${SASS_SPEC_SPEC_DIR}/basic/result.css + cat ${SASS_SPEC_SPEC_DIR}/basic/input.scss | ${SASSC_BIN} --precision 5 --plugin-path plugins/libsass-${PLUGIN}/build -I ${SASS_SPEC_SPEC_DIR}/basic --sourcemap > /dev/null +fi +RETVAL=$?; if [ "$RETVAL" != "0" ]; then exit $RETVAL; fi + +diff ${SASS_SPEC_SPEC_DIR}/basic/expected_output.css ${SASS_SPEC_SPEC_DIR}/basic/result.css +RETVAL=$?; if [ "$RETVAL" != "0" ]; then exit $RETVAL; fi diff --git a/node_modules/node-sass/src/libsass/script/ci-install-compiler b/node_modules/node-sass/src/libsass/script/ci-install-compiler new file mode 100755 index 0000000..3a68b3a --- /dev/null +++ b/node_modules/node-sass/src/libsass/script/ci-install-compiler @@ -0,0 +1,6 @@ +#!/bin/bash + +gem install minitest +gem install minitap + +pip2 install --user 'requests[security]' diff --git a/node_modules/node-sass/src/libsass/script/ci-install-deps b/node_modules/node-sass/src/libsass/script/ci-install-deps new file mode 100755 index 0000000..27b485a --- /dev/null +++ b/node_modules/node-sass/src/libsass/script/ci-install-deps @@ -0,0 +1,20 @@ +#!/bin/bash +if [ "x$COVERAGE" == "xyes" ]; then + pip2 install --user gcovr + pip2 install --user cpp-coveralls +else + echo "no dependencies to install" +fi + +if [ "x$AUTOTOOLS" == "xyes" ]; then + AUTOTOOLS=yes + + if [ "$TRAVIS_OS_NAME" == "linux" ]; then + sudo add-apt-repository -y ppa:rbose-debianizer/automake &> /dev/null + sudo apt-get -qq update + sudo apt-get -qq install automake + fi + +fi + +exit 0 diff --git a/node_modules/node-sass/src/libsass/script/ci-report-coverage b/node_modules/node-sass/src/libsass/script/ci-report-coverage new file mode 100755 index 0000000..495cb05 --- /dev/null +++ b/node_modules/node-sass/src/libsass/script/ci-report-coverage @@ -0,0 +1,42 @@ +#!/bin/bash + +if [ "x$COVERAGE" = "xyes" ]; then + + # find / -name "gcovr" + # find / -name "coveralls" + # this is only needed for mac os x builds! + PATH=$PATH:/Users/travis/Library/Python/2.7/bin/ + + + # exclude some directories from profiling (.libs is from autotools) + export EXCLUDE_COVERAGE="--exclude plugins + --exclude sassc/sassc.c + --exclude src/sass-spec + --exclude src/.libs + --exclude src/debug.hpp + --exclude src/json.cpp + --exclude src/json.hpp + --exclude src/cencode.c + --exclude src/b64 + --exclude src/utf8 + --exclude src/utf8_string.hpp + --exclude src/utf8.h + --exclude src/utf8_string.cpp + --exclude src/sass2scss.h + --exclude src/sass2scss.cpp + --exclude src/test + --exclude src/posix + --exclude src/debugger.hpp" + # debug used gcov version + # option not available on mac + if [ "$TRAVIS_OS_NAME" != "osx" ]; then + gcov -v + fi + # create summarized report + gcovr -r . + # submit report to coveralls.io + coveralls $EXCLUDE_COVERAGE --gcov-options '\-lp' + +else + echo "skip coverage reporting" +fi diff --git a/node_modules/node-sass/src/libsass/script/spec b/node_modules/node-sass/src/libsass/script/spec new file mode 100755 index 0000000..d0b864a --- /dev/null +++ b/node_modules/node-sass/src/libsass/script/spec @@ -0,0 +1,5 @@ +#!/bin/bash + +script/bootstrap + +make $MAKE_OPTS test_build diff --git a/node_modules/node-sass/src/libsass/script/tap-driver b/node_modules/node-sass/src/libsass/script/tap-driver new file mode 100755 index 0000000..ed8a9a9 --- /dev/null +++ b/node_modules/node-sass/src/libsass/script/tap-driver @@ -0,0 +1,652 @@ +#!/usr/bin/env sh +# Copyright (C) 2011-2013 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to <bug-automake@gnu.org> or send patches to +# <automake-patches@gnu.org>. + +scriptversion=2011-12-27.17; # UTC + +# Make unconditional expansion of undefined variables an error. This +# helps a lot in preventing typo-related bugs. +set -u + +me=tap-driver.sh + +fatal () +{ + echo "$me: fatal: $*" >&2 + exit 1 +} + +usage_error () +{ + echo "$me: $*" >&2 + print_usage >&2 + exit 2 +} + +print_usage () +{ + cat <<END +Usage: + tap-driver.sh --test-name=NAME --log-file=PATH --trs-file=PATH + [--expect-failure={yes|no}] [--color-tests={yes|no}] + [--enable-hard-errors={yes|no}] [--ignore-exit] + [--diagnostic-string=STRING] [--merge|--no-merge] + [--comments|--no-comments] [--] TEST-COMMAND +The \`--test-name', \`--log-file' and \`--trs-file' options are mandatory. +END +} + +# TODO: better error handling in option parsing (in particular, ensure +# TODO: $log_file, $trs_file and $test_name are defined). +test_name= # Used for reporting. +log_file= # Where to save the result and output of the test script. +trs_file= # Where to save the metadata of the test run. +expect_failure=0 +color_tests=0 +merge=0 +ignore_exit=0 +comments=0 +diag_string='#' +while test $# -gt 0; do + case $1 in + --help) print_usage; exit $?;; + --version) echo "$me $scriptversion"; exit $?;; + --test-name) test_name=$2; shift;; + --log-file) log_file=$2; shift;; + --trs-file) trs_file=$2; shift;; + --color-tests) color_tests=$2; shift;; + --expect-failure) expect_failure=$2; shift;; + --enable-hard-errors) shift;; # No-op. + --merge) merge=1;; + --no-merge) merge=0;; + --ignore-exit) ignore_exit=1;; + --comments) comments=1;; + --no-comments) comments=0;; + --diagnostic-string) diag_string=$2; shift;; + --) shift; break;; + -*) usage_error "invalid option: '$1'";; + esac + shift +done + +test $# -gt 0 || usage_error "missing test command" + +case $expect_failure in + yes) expect_failure=1;; + *) expect_failure=0;; +esac + +if test $color_tests = yes; then + init_colors=' + color_map["red"]="[0;31m" # Red. + color_map["grn"]="[0;32m" # Green. + color_map["lgn"]="[1;32m" # Light green. + color_map["blu"]="[1;34m" # Blue. + color_map["mgn"]="[0;35m" # Magenta. + color_map["std"]="[m" # No color. + color_for_result["ERROR"] = "mgn" + color_for_result["PASS"] = "grn" + color_for_result["XPASS"] = "red" + color_for_result["FAIL"] = "red" + color_for_result["XFAIL"] = "lgn" + color_for_result["SKIP"] = "blu"' +else + init_colors='' +fi + +# :; is there to work around a bug in bash 3.2 (and earlier) which +# does not always set '$?' properly on redirection failure. +# See the Autoconf manual for more details. +:;{ + ( + # Ignore common signals (in this subshell only!), to avoid potential + # problems with Korn shells. Some Korn shells are known to propagate + # to themselves signals that have killed a child process they were + # waiting for; this is done at least for SIGINT (and usually only for + # it, in truth). Without the `trap' below, such a behaviour could + # cause a premature exit in the current subshell, e.g., in case the + # test command it runs gets terminated by a SIGINT. Thus, the awk + # script we are piping into would never seen the exit status it + # expects on its last input line (which is displayed below by the + # last `echo $?' statement), and would thus die reporting an internal + # error. + # For more information, see the Autoconf manual and the threads: + # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html> + # <http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-February/004121.html> + trap : 1 3 2 13 15 + if test $merge -gt 0; then + exec 2>&1 + else + exec 2>&3 + fi + "$@" + echo $? + ) | LC_ALL=C ${AM_TAP_AWK-awk} \ + -v me="$me" \ + -v test_script_name="$test_name" \ + -v log_file="$log_file" \ + -v trs_file="$trs_file" \ + -v expect_failure="$expect_failure" \ + -v merge="$merge" \ + -v ignore_exit="$ignore_exit" \ + -v comments="$comments" \ + -v diag_string="$diag_string" \ +' +# FIXME: the usages of "cat >&3" below could be optimized when using +# FIXME: GNU awk, and/on on systems that supports /dev/fd/. + +# Implementation note: in what follows, `result_obj` will be an +# associative array that (partly) simulates a TAP result object +# from the `TAP::Parser` perl module. + +## ----------- ## +## FUNCTIONS ## +## ----------- ## + +function fatal(msg) +{ + print me ": " msg | "cat >&2" + exit 1 +} + +function abort(where) +{ + fatal("internal error " where) +} + +# Convert a boolean to a "yes"/"no" string. +function yn(bool) +{ + return bool ? "yes" : "no"; +} + +function add_test_result(result) +{ + if (!test_results_index) + test_results_index = 0 + test_results_list[test_results_index] = result + test_results_index += 1 + test_results_seen[result] = 1; +} + +# Whether the test script should be re-run by "make recheck". +function must_recheck() +{ + for (k in test_results_seen) + if (k != "XFAIL" && k != "PASS" && k != "SKIP") + return 1 + return 0 +} + +# Whether the content of the log file associated to this test should +# be copied into the "global" test-suite.log. +function copy_in_global_log() +{ + for (k in test_results_seen) + if (k != "PASS") + return 1 + return 0 +} + +# FIXME: this can certainly be improved ... +function get_global_test_result() +{ + if ("ERROR" in test_results_seen) + return "ERROR" + if ("FAIL" in test_results_seen || "XPASS" in test_results_seen) + return "FAIL" + all_skipped = 1 + for (k in test_results_seen) + if (k != "SKIP") + all_skipped = 0 + if (all_skipped) + return "SKIP" + return "PASS"; +} + +function stringify_result_obj(result_obj) +{ + if (result_obj["is_unplanned"] || result_obj["number"] != testno) + return "ERROR" + + if (plan_seen == LATE_PLAN) + return "ERROR" + + if (result_obj["directive"] == "TODO") + return result_obj["is_ok"] ? "XPASS" : "XFAIL" + + if (result_obj["directive"] == "SKIP") + return result_obj["is_ok"] ? "SKIP" : COOKED_FAIL; + + if (length(result_obj["directive"])) + abort("in function stringify_result_obj()") + + return result_obj["is_ok"] ? COOKED_PASS : COOKED_FAIL +} + +function decorate_result(result) +{ + color_name = color_for_result[result] + if (color_name) + return color_map[color_name] "" result "" color_map["std"] + # If we are not using colorized output, or if we do not know how + # to colorize the given result, we should return it unchanged. + return result +} + +function report(result, details) +{ + if (result ~ /^(X?(PASS|FAIL)|SKIP|ERROR)/) + { + msg = ": " test_script_name + add_test_result(result) + } + else if (result == "#") + { + msg = " " test_script_name ":" + } + else + { + abort("in function report()") + } + if (length(details)) + msg = msg " " details + # Output on console might be colorized. + print decorate_result(result) msg + # Log the result in the log file too, to help debugging (this is + # especially true when said result is a TAP error or "Bail out!"). + print result msg | "cat >&3"; +} + +function testsuite_error(error_message) +{ + report("ERROR", "- " error_message) +} + +function handle_tap_result() +{ + details = result_obj["number"]; + if (length(result_obj["description"])) + details = details " " result_obj["description"] + + if (plan_seen == LATE_PLAN) + { + details = details " # AFTER LATE PLAN"; + } + else if (result_obj["is_unplanned"]) + { + details = details " # UNPLANNED"; + } + else if (result_obj["number"] != testno) + { + details = sprintf("%s # OUT-OF-ORDER (expecting %d)", + details, testno); + } + else if (result_obj["directive"]) + { + details = details " # " result_obj["directive"]; + if (length(result_obj["explanation"])) + details = details " " result_obj["explanation"] + } + + report(stringify_result_obj(result_obj), details) +} + +# `skip_reason` should be empty whenever planned > 0. +function handle_tap_plan(planned, skip_reason) +{ + planned += 0 # Avoid getting confused if, say, `planned` is "00" + if (length(skip_reason) && planned > 0) + abort("in function handle_tap_plan()") + if (plan_seen) + { + # Error, only one plan per stream is acceptable. + testsuite_error("multiple test plans") + return; + } + planned_tests = planned + # The TAP plan can come before or after *all* the TAP results; we speak + # respectively of an "early" or a "late" plan. If we see the plan line + # after at least one TAP result has been seen, assume we have a late + # plan; in this case, any further test result seen after the plan will + # be flagged as an error. + plan_seen = (testno >= 1 ? LATE_PLAN : EARLY_PLAN) + # If testno > 0, we have an error ("too many tests run") that will be + # automatically dealt with later, so do not worry about it here. If + # $plan_seen is true, we have an error due to a repeated plan, and that + # has already been dealt with above. Otherwise, we have a valid "plan + # with SKIP" specification, and should report it as a particular kind + # of SKIP result. + if (planned == 0 && testno == 0) + { + if (length(skip_reason)) + skip_reason = "- " skip_reason; + report("SKIP", skip_reason); + } +} + +function extract_tap_comment(line) +{ + if (index(line, diag_string) == 1) + { + # Strip leading `diag_string` from `line`. + line = substr(line, length(diag_string) + 1) + # And strip any leading and trailing whitespace left. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + # Return what is left (if any). + return line; + } + return ""; +} + +# When this function is called, we know that line is a TAP result line, +# so that it matches the (perl) RE "^(not )?ok\b". +function setup_result_obj(line) +{ + # Get the result, and remove it from the line. + result_obj["is_ok"] = (substr(line, 1, 2) == "ok" ? 1 : 0) + sub("^(not )?ok[ \t]*", "", line) + + # If the result has an explicit number, get it and strip it; otherwise, + # automatically assing the next progresive number to it. + if (line ~ /^[0-9]+$/ || line ~ /^[0-9]+[^a-zA-Z0-9_]/) + { + match(line, "^[0-9]+") + # The final `+ 0` is to normalize numbers with leading zeros. + result_obj["number"] = substr(line, 1, RLENGTH) + 0 + line = substr(line, RLENGTH + 1) + } + else + { + result_obj["number"] = testno + } + + if (plan_seen == LATE_PLAN) + # No further test results are acceptable after a "late" TAP plan + # has been seen. + result_obj["is_unplanned"] = 1 + else if (plan_seen && testno > planned_tests) + result_obj["is_unplanned"] = 1 + else + result_obj["is_unplanned"] = 0 + + # Strip trailing and leading whitespace. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + + # This will have to be corrected if we have a "TODO"/"SKIP" directive. + result_obj["description"] = line + result_obj["directive"] = "" + result_obj["explanation"] = "" + + if (index(line, "#") == 0) + return # No possible directive, nothing more to do. + + # Directives are case-insensitive. + rx = "[ \t]*#[ \t]*([tT][oO][dD][oO]|[sS][kK][iI][pP])[ \t]*" + + # See whether we have the directive, and if yes, where. + pos = match(line, rx "$") + if (!pos) + pos = match(line, rx "[^a-zA-Z0-9_]") + + # If there was no TAP directive, we have nothing more to do. + if (!pos) + return + + # Let`s now see if the TAP directive has been escaped. For example: + # escaped: ok \# SKIP + # not escaped: ok \\# SKIP + # escaped: ok \\\\\# SKIP + # not escaped: ok \ # SKIP + if (substr(line, pos, 1) == "#") + { + bslash_count = 0 + for (i = pos; i > 1 && substr(line, i - 1, 1) == "\\"; i--) + bslash_count += 1 + if (bslash_count % 2) + return # Directive was escaped. + } + + # Strip the directive and its explanation (if any) from the test + # description. + result_obj["description"] = substr(line, 1, pos - 1) + # Now remove the test description from the line, that has been dealt + # with already. + line = substr(line, pos) + # Strip the directive, and save its value (normalized to upper case). + sub("^[ \t]*#[ \t]*", "", line) + result_obj["directive"] = toupper(substr(line, 1, 4)) + line = substr(line, 5) + # Now get the explanation for the directive (if any), with leading + # and trailing whitespace removed. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + result_obj["explanation"] = line +} + +function get_test_exit_message(status) +{ + if (status == 0) + return "" + if (status !~ /^[1-9][0-9]*$/) + abort("getting exit status") + if (status < 127) + exit_details = "" + else if (status == 127) + exit_details = " (command not found?)" + else if (status >= 128 && status <= 255) + exit_details = sprintf(" (terminated by signal %d?)", status - 128) + else if (status > 256 && status <= 384) + # We used to report an "abnormal termination" here, but some Korn + # shells, when a child process die due to signal number n, can leave + # in $? an exit status of 256+n instead of the more standard 128+n. + # Apparently, both behaviours are allowed by POSIX (2008), so be + # prepared to handle them both. See also Austing Group report ID + # 0000051 <http://www.austingroupbugs.net/view.php?id=51> + exit_details = sprintf(" (terminated by signal %d?)", status - 256) + else + # Never seen in practice. + exit_details = " (abnormal termination)" + return sprintf("exited with status %d%s", status, exit_details) +} + +function write_test_results() +{ + print ":global-test-result: " get_global_test_result() > trs_file + print ":recheck: " yn(must_recheck()) > trs_file + print ":copy-in-global-log: " yn(copy_in_global_log()) > trs_file + for (i = 0; i < test_results_index; i += 1) + print ":test-result: " test_results_list[i] > trs_file + close(trs_file); +} + +BEGIN { + +## ------- ## +## SETUP ## +## ------- ## + +'"$init_colors"' + +# Properly initialized once the TAP plan is seen. +planned_tests = 0 + +COOKED_PASS = expect_failure ? "XPASS": "PASS"; +COOKED_FAIL = expect_failure ? "XFAIL": "FAIL"; + +# Enumeration-like constants to remember which kind of plan (if any) +# has been seen. It is important that NO_PLAN evaluates "false" as +# a boolean. +NO_PLAN = 0 +EARLY_PLAN = 1 +LATE_PLAN = 2 + +testno = 0 # Number of test results seen so far. +bailed_out = 0 # Whether a "Bail out!" directive has been seen. + +# Whether the TAP plan has been seen or not, and if yes, which kind +# it is ("early" is seen before any test result, "late" otherwise). +plan_seen = NO_PLAN + +## --------- ## +## PARSING ## +## --------- ## + +is_first_read = 1 + +while (1) + { + # Involutions required so that we are able to read the exit status + # from the last input line. + st = getline + if (st < 0) # I/O error. + fatal("I/O error while reading from input stream") + else if (st == 0) # End-of-input + { + if (is_first_read) + abort("in input loop: only one input line") + break + } + if (is_first_read) + { + is_first_read = 0 + nextline = $0 + continue + } + else + { + curline = nextline + nextline = $0 + $0 = curline + } + # Copy any input line verbatim into the log file. + print | "cat >&3" + # Parsing of TAP input should stop after a "Bail out!" directive. + if (bailed_out) + continue + + # TAP test result. + if ($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/) + { + testno += 1 + setup_result_obj($0) + handle_tap_result() + } + # TAP plan (normal or "SKIP" without explanation). + else if ($0 ~ /^1\.\.[0-9]+[ \t]*$/) + { + # The next two lines will put the number of planned tests in $0. + sub("^1\\.\\.", "") + sub("[^0-9]*$", "") + handle_tap_plan($0, "") + continue + } + # TAP "SKIP" plan, with an explanation. + else if ($0 ~ /^1\.\.0+[ \t]*#/) + { + # The next lines will put the skip explanation in $0, stripping + # any leading and trailing whitespace. This is a little more + # tricky in truth, since we want to also strip a potential leading + # "SKIP" string from the message. + sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "") + sub("[ \t]*$", ""); + handle_tap_plan(0, $0) + } + # "Bail out!" magic. + # Older versions of prove and TAP::Harness (e.g., 3.17) did not + # recognize a "Bail out!" directive when preceded by leading + # whitespace, but more modern versions (e.g., 3.23) do. So we + # emulate the latter, "more modern" behaviour. + else if ($0 ~ /^[ \t]*Bail out!/) + { + bailed_out = 1 + # Get the bailout message (if any), with leading and trailing + # whitespace stripped. The message remains stored in `$0`. + sub("^[ \t]*Bail out![ \t]*", ""); + sub("[ \t]*$", ""); + # Format the error message for the + bailout_message = "Bail out!" + if (length($0)) + bailout_message = bailout_message " " $0 + testsuite_error(bailout_message) + } + # Maybe we have too look for dianogtic comments too. + else if (comments != 0) + { + comment = extract_tap_comment($0); + if (length(comment)) + report("#", comment); + } + } + +## -------- ## +## FINISH ## +## -------- ## + +# A "Bail out!" directive should cause us to ignore any following TAP +# error, as well as a non-zero exit status from the TAP producer. +if (!bailed_out) + { + if (!plan_seen) + { + testsuite_error("missing test plan") + } + else if (planned_tests != testno) + { + bad_amount = testno > planned_tests ? "many" : "few" + testsuite_error(sprintf("too %s tests run (expected %d, got %d)", + bad_amount, planned_tests, testno)) + } + if (!ignore_exit) + { + # Fetch exit status from the last line. + exit_message = get_test_exit_message(nextline) + if (exit_message) + testsuite_error(exit_message) + } + } + +write_test_results() + +exit 0 + +} # End of "BEGIN" block. +' + +# TODO: document that we consume the file descriptor 3 :-( +} 3>"$log_file" + +test $? -eq 0 || fatal "I/O or internal error" + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/node_modules/node-sass/src/libsass/script/tap-runner b/node_modules/node-sass/src/libsass/script/tap-runner new file mode 100755 index 0000000..56c13bf --- /dev/null +++ b/node_modules/node-sass/src/libsass/script/tap-runner @@ -0,0 +1 @@ +$@ $TEST_FLAGS --tap --silent | tapout tap diff --git a/node_modules/node-sass/src/libsass/script/test-leaks.pl b/node_modules/node-sass/src/libsass/script/test-leaks.pl new file mode 100755 index 0000000..bfb8653 --- /dev/null +++ b/node_modules/node-sass/src/libsass/script/test-leaks.pl @@ -0,0 +1,103 @@ +#!/usr/bin/perl +############################################################ +# this perl script is meant for developers only! +# it will run all spec-tests (without verifying the +# results) via valgrind to detect possible leaks. +# expect that it takes 1h or more to finish! +############################################################ +# Prerequisite install: `cpan Parallel::Runner` +# You may also need to install `cpan File::Find` +# You may also need to install `cpan IPC::Run3` +############################################################ +# usage: `perl test-leaks.pl [threads]` +# example: `time perl test-leaks.pl 4` +############################################################ +# leaks will be reported in "mem-leaks.log" +############################################################ + +use strict; +use warnings; + +############################################################ +# configurations (you may adjust) +############################################################ + +# number of threads to use +my $threads = $ARGV[0] || 8; + +# the github repositories to checkout +# if you need other branch, clone manually! +my $sassc = "https://www.github.com/sass/sassc"; +my $specs = "https://www.github.com/sass/sass-spec"; + +############################################################ +# load modules +############################################################ + +use IPC::Run3; +use IO::Handle; +use Fcntl qw(:flock); +use File::Find::Rule; +use Parallel::Runner; +use List::Util qw(shuffle); + +############################################################ +# check prerequisites +############################################################ + +unless (-d "../sassc") { + warn "sassc folder not found\n"; + warn "trying to checkout via git\n"; + system("git", "clone", $sassc, "../sassc"); + die "git command did not exit gracefully" if $?; +} + +unless (-d "../sass-spec") { + warn "sass-spec folder not found\n"; + warn "trying to checkout via git\n"; + system("git", "clone", $specs, "../sass-spec"); + die "git command did not exit gracefully" if $?; +} + +unless (-f "../sassc/bin/sassc") { + warn "sassc executable not found\n"; + warn "trying to compile via make\n"; + system("make", "-C", "../sassc", "-j", $threads); + die "make command did not exit gracefully" if $?; +} + +############################################################ +# main runner code +############################################################ + +my $root = "../sass-spec/spec"; +my @files = File::Find::Rule->file() + ->name('input.scss')->in($root); + +open(my $leaks, ">", "mem-leaks.log"); +die "Cannot open log" unless $leaks; +my $runner = Parallel::Runner->new($threads); +die "Cannot start runner" unless $runner; + +print "##########################\n"; +print "Testing $#files spec files\n"; +print "##########################\n"; + +foreach my $file (shuffle @files) { + $runner->run(sub { + $| = 1; select STDOUT; + my $cmd = sprintf('../sassc/bin/sassc %s', $file); + my $check = sprintf('valgrind --leak-check=yes %s', $cmd); + run3($check, undef, \ my $out, \ my $err); + if ($err =~ m/in use at exit: 0 bytes in 0 blocks/) { + print "."; # print success indicator + } else { + print "F"; # print error indicator + flock($leaks, LOCK_EX) or die "Cannot lock log"; + $leaks->printflush("#" x 80, "\n", $err, "\n"); + flock($leaks, LOCK_UN) or die "Cannot unlock log"; + } + }); +} + +$runner->finish; |