aboutsummaryrefslogtreecommitdiff
#!/bin/sh

# GNU Guix --- Functional package management for GNU
# Copyright © 2012, 2013, 2014, 2015, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2017 Eric Bavier <bavier@cray.com>
#
# This file is part of GNU Guix.
#
# GNU Guix 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 3 of the License, or (at
# your option) any later version.
#
# GNU Guix 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 GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

# Usage: ./pre-inst-env COMMAND ARG...
#
# Run COMMAND in a pre-installation environment.  Typical use is
# "./pre-inst-env guix build hello".

# By default we may end up with absolute directory names that contain '..',
# which get into $GUILE_LOAD_PATH, leading to '..' in the module file names
# recorded by Guile.  To avoid that, make sure we get a real absolute
# directory name.  Additionally, use '-P' to get the canonical directory name
# so that Guile's 'relative' %file-port-name-canonicalization can actually
# work (see <http://bugs.gnu.org/17935>.)
abs_top_srcdir="`cd "@abs_top_srcdir@" > /dev/null; pwd -P`"
abs_top_builddir="`cd "@abs_top_builddir@" > /dev/null; pwd -P`"

GUILE_LOAD_COMPILED_PATH="$abs_top_builddir${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
GUILE_LOAD_PATH="$abs_top_builddir:$abs_top_srcdir${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH"
export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH

# Define $PATH so that `guix' and friends are easily found.

PATH="$abs_top_builddir/scripts:$abs_top_builddir:$PATH"
export PATH

# The daemon invokes 'guix'; tell it which one to use.
GUIX="$abs_top_builddir/scripts/guix"
export GUIX

# Define $GUIX_UNINSTALLED to prevent `guix' from
# prepending @guilemoduledir@ to the Guile load paths.

GUIX_UNINSTALLED=1
export GUIX_UNINSTALLED

exec "$@"
='/tracifyjs/commit/test/ufuzz/index.js?h=templatifyjs&id=ec0440f26492ff548a670605f232de8e14a93390'>ec0440f26492ff548a670605f232de8e14a93390 (patch) treeab33d0e2cf42e16687c2b668a086752aaffcefd9 /test/ufuzz/index.js parent81254f67e473f2a1db8341de26cd923f9c592e17 (diff)downloadtracifyjs-ec0440f26492ff548a670605f232de8e14a93390.tar.gz
tracifyjs-ec0440f26492ff548a670605f232de8e14a93390.zip
fix corner cases with `import` (#4709)
fixes #4708
Diffstat (limited to 'test/ufuzz/index.js')
-rw-r--r--test/ufuzz/index.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js
index b066e2fa..f38cdd96 100644
--- a/test/ufuzz/index.js
+++ b/test/ufuzz/index.js
@@ -1020,22 +1020,30 @@ function createStatement(recurmax, canThrow, canBreak, canContinue, cannotReturn
return "switch (" + createExpression(recurmax, COMMA_OK, stmtDepth, canThrow) + ") { " + createSwitchParts(recurmax, 4, canThrow, canBreak, canContinue, cannotReturn, stmtDepth) + "}";
case STMT_VAR:
if (SUPPORT.destructuring && stmtDepth == 1 && rng(5) == 0) {
- unique_vars.push("c");
- var s = rng(2) ? " " + createVarName(MANDATORY) : "";
+ unique_vars.push("a", "b", "c", "undefined", "NaN", "Infinity");
+ var s = "";
+ if (rng(2)) {
+ var name = createVarName(MANDATORY);
+ block_vars.push(name);
+ s += " " + name;
+ }
if (rng(10)) {
if (s) s += ",";
if (rng(2)) {
- s += " * as " + createVarName(MANDATORY);
+ var name = createVarName(MANDATORY);
+ block_vars.push(name);
+ s += " * as " + name;
} else {
var names = [];
for (var i = rng(4); --i >= 0;) {
var name = createVarName(MANDATORY);
+ block_vars.push(name);
names.push(rng(2) ? getDotKey() + " as " + name : name);
}
s += " { " + names.join(", ") + " }";
}
}
- unique_vars.pop();
+ unique_vars.length -= 6;
if (s) s += " from";
return "import" + s + ' "path/to/module.js";';
} else if (SUPPORT.destructuring && rng(20) == 0) {
@@ -2217,6 +2225,10 @@ function is_error_recursion(ex) {
return ex.name == "RangeError" && /Invalid string length|Maximum call stack size exceeded/.test(ex.message);
}
+function is_error_redeclaration(ex) {
+ return ex.name == "SyntaxError" && /already been declared|redeclaration/.test(ex.message);
+}
+
function is_error_destructuring(ex) {
return ex.name == "TypeError" && /^Cannot destructure /.test(ex.message);
}
@@ -2409,6 +2421,10 @@ for (var round = 1; round <= num_iterations; round++) {
ok = sandbox.same_stdout(original_strict, uglify_strict);
}
}
+ // ignore difference in error message caused by `import` symbol redeclaration
+ if (!ok && errored && /\bimport\b/.test(original_code)) {
+ if (is_error_redeclaration(uglify_result) && is_error_redeclaration(original_result)) ok = true;
+ }
// ignore difference in error message caused by `in`
if (!ok && errored && is_error_in(uglify_result) && is_error_in(original_result)) ok = true;
// ignore difference in error message caused by spread syntax