From 58362d5ec7bcc9c4522f185a277b2608cc99b223 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 9 Mar 2021 19:34:30 +0000 Subject: [PATCH] build Math.js for verification testing (#4758) --- .github/workflows/build.yml | 4 +- bin/uglifyjs | 16 ++- test/release/acorn.sh | 5 +- test/release/buble.sh | 5 +- test/release/butternut.sh | 5 +- test/release/mathjs.sh | 194 ++++++++++++++++++++++++++++++++++++ test/release/rollup-es.sh | 5 +- test/release/rollup-ts.sh | 5 +- test/release/sucrase.sh | 8 +- 9 files changed, 231 insertions(+), 16 deletions(-) create mode 100755 test/release/mathjs.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 575df5b2..7ef68a71 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: fail-fast: false matrix: options: [ '-mb braces', '-mc', '--toplevel -mc passes=10,pure_getters,unsafe' ] - script: [ acorn.sh, buble.sh, butternut.sh, rollup-es.sh, rollup-ts.sh, sucrase.sh ] + script: [ acorn.sh, buble.sh, butternut.sh, mathjs.sh, rollup-es.sh, rollup-ts.sh, sucrase.sh ] include: - node: '14' script: acorn.sh @@ -17,6 +17,8 @@ jobs: script: buble.sh - node: '14' script: butternut.sh + - node: '14' + script: mathjs.sh - node: '8' script: rollup-es.sh - node: '14' diff --git a/bin/uglifyjs b/bin/uglifyjs index 35f06412..cd37b20b 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -113,6 +113,9 @@ function process_option(name, no_value) { " --warn Print warning messages.", " --webkit Support non-standard Safari/Webkit.", " --wrap Embed everything as a function with “exports” corresponding to “name” globally.", + "", + "(internal debug use only)", + " --in-situ Warning: replaces original source files with minified output.", " --reduce-test Reduce a standalone test case (assumes cloned repository).", ].join("\n")); } @@ -194,6 +197,7 @@ function process_option(name, no_value) { case "no-rename": options.rename = false; break; + case "in-situ": case "reduce-test": case "self": break; @@ -254,7 +258,17 @@ if (specified["self"]) { if (!options.wrap) options.wrap = "UglifyJS"; paths = UglifyJS.FILES; } -if (paths.length) { +if (specified["in-situ"]) { + if (output || specified["reduce-test"] || specified["self"]) fatal("incompatible options specified"); + paths.forEach(function(name) { + print(name); + if (/^ast|spidermonkey$/.test(name)) fatal("invalid file name specified"); + files = {}; + files[convert_path(name)] = read_file(name); + output = name; + run(); + }); +} else if (paths.length) { simple_glob(paths).forEach(function(name) { files[convert_path(name)] = read_file(name); }); diff --git a/test/release/acorn.sh b/test/release/acorn.sh index 99e5c93d..0ebfc9ec 100755 --- a/test/release/acorn.sh +++ b/test/release/acorn.sh @@ -4,13 +4,14 @@ alias uglify-js=$PWD/bin/uglifyjs UGLIFY_OPTIONS=$@ minify_in_situ() { + ARGS="$UGLIFY_OPTIONS --in-situ" DIRS="$1" echo '> uglify-js' $DIRS $UGLIFY_OPTIONS for i in `find $DIRS -name '*.js'` do - echo "$i" - uglify-js "$i" $UGLIFY_OPTIONS -o "$i" + ARGS="$ARGS $i" done + uglify-js $ARGS } rm -rf tmp/acorn \ diff --git a/test/release/buble.sh b/test/release/buble.sh index 6a14ecad..30455441 100755 --- a/test/release/buble.sh +++ b/test/release/buble.sh @@ -4,13 +4,14 @@ alias uglify-js=$PWD/bin/uglifyjs UGLIFY_OPTIONS=$@ minify_in_situ() { + ARGS="$UGLIFY_OPTIONS --in-situ" DIRS="$1" echo '> uglify-js' $DIRS $UGLIFY_OPTIONS for i in `find $DIRS -name '*.js'` do - echo "$i" - uglify-js "$i" $UGLIFY_OPTIONS -o "$i" + ARGS="$ARGS $i" done + uglify-js $ARGS } rm -rf tmp/buble \ diff --git a/test/release/butternut.sh b/test/release/butternut.sh index b62c9371..fa5500b1 100755 --- a/test/release/butternut.sh +++ b/test/release/butternut.sh @@ -4,13 +4,14 @@ alias uglify-js=$PWD/bin/uglifyjs UGLIFY_OPTIONS=$@ minify_in_situ() { + ARGS="$UGLIFY_OPTIONS --in-situ" DIRS="$1" echo '> uglify-js' $DIRS $UGLIFY_OPTIONS for i in `find $DIRS -name '*.js'` do - echo "$i" - uglify-js "$i" $UGLIFY_OPTIONS -o "$i" + ARGS="$ARGS $i" done + uglify-js $ARGS } rm -rf tmp/butternut \ diff --git a/test/release/mathjs.sh b/test/release/mathjs.sh new file mode 100755 index 00000000..b45c3918 --- /dev/null +++ b/test/release/mathjs.sh @@ -0,0 +1,194 @@ +#!/bin/sh + +alias uglify-js=$PWD/bin/uglifyjs +UGLIFY_OPTIONS=$@ + +minify_in_situ() { + ARGS="$UGLIFY_OPTIONS --in-situ" + DIRS="$1" + echo '> uglify-js' $DIRS $UGLIFY_OPTIONS + for i in `find $DIRS -name '*.js'` + do + ARGS="$ARGS $i" + done + for i in `find $DIRS -name '*.mjs'` + do + ARGS="$ARGS $i" + done + uglify-js $ARGS +} + +rm -rf tmp/mathjs \ +&& git clone --depth 1 --branch v9.2.0 https://github.com/josdejong/mathjs.git tmp/mathjs \ +&& cd tmp/mathjs \ +&& rm -rf .git/hooks \ +&& patch -l -p1 < uglify-js' $DIRS $UGLIFY_OPTIONS for i in `find $DIRS -name '*.js'` do - echo "$i" - uglify-js "$i" $UGLIFY_OPTIONS -o "$i" + ARGS="$ARGS $i" done + uglify-js $ARGS } rm -rf tmp/rollup \ diff --git a/test/release/rollup-ts.sh b/test/release/rollup-ts.sh index d1888a5c..422e1ea1 100755 --- a/test/release/rollup-ts.sh +++ b/test/release/rollup-ts.sh @@ -4,13 +4,14 @@ alias uglify-js=$PWD/bin/uglifyjs UGLIFY_OPTIONS=$@ minify_in_situ() { + ARGS="$UGLIFY_OPTIONS --in-situ" DIRS="$1" echo '> uglify-js' $DIRS $UGLIFY_OPTIONS for i in `find $DIRS -name '*.js'` do - echo "$i" - uglify-js "$i" $UGLIFY_OPTIONS -o "$i" + ARGS="$ARGS $i" done + uglify-js $ARGS for i in `find $DIRS -name '*.ts' | grep -v '\.d\.ts'` do echo "$i" diff --git a/test/release/sucrase.sh b/test/release/sucrase.sh index 4ac04d9d..dfefb140 100755 --- a/test/release/sucrase.sh +++ b/test/release/sucrase.sh @@ -4,18 +4,18 @@ alias uglify-js=$PWD/bin/uglifyjs UGLIFY_OPTIONS=$@ minify_in_situ() { + ARGS="$UGLIFY_OPTIONS --in-situ" DIRS="$1" echo '> uglify-js' $DIRS $UGLIFY_OPTIONS for i in `find $DIRS -name '*.js'` do - echo "$i" - uglify-js "$i" $UGLIFY_OPTIONS -o "$i" + ARGS="$ARGS $i" done for i in `find $DIRS -name '*.mjs'` do - echo "$i" - uglify-js "$i" $UGLIFY_OPTIONS -o "$i" + ARGS="$ARGS $i" done + uglify-js $ARGS for i in `find $DIRS -name '*.ts' | grep -v '\.d\.ts'` do echo "$i" -- 2.34.1