summaryrefslogtreecommitdiffstats
path: root/yql/essentials/tools/yql_highlight/ut/test.sh
blob: f6055825294c8f42b5a74d81f13f1155017f9775 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash

set -e

cd "$(dirname "$0")"

MODE="${1:-yql}"
THEME="${2:-light}"

echo "Generating highlighting configurations..."
ya make ..

DIR=$(mktemp -d)
echo "Working directory is created at $DIR"

function copy() {
    cp "$1" "$DIR/$2"
}

cp "monarch.template.ts" "$DIR/monarch.template.ts"
cp "test.template.html" "$DIR/test.template.html"
cp "test.py" "$DIR/test.py"
cp "query.yql" "$DIR/query.yql"
cp "query.yqls" "$DIR/query.yqls"
cp "../artifact/YQL.monarch.json" "$DIR/YQL.monarch.json"
cp "../artifact/YQL.tmLanguage.json" "$DIR/YQL.tmLanguage.json"
cp "../artifact/YQL.highlightjs.json" "$DIR/YQL.highlightjs.json"
cp "../artifact/YQLs.monarch.json" "$DIR/YQLs.monarch.json"
cp "../artifact/YQLs.tmLanguage.json" "$DIR/YQLs.tmLanguage.json"
cp "../artifact/YQLs.highlightjs.json" "$DIR/YQLs.highlightjs.json"

cd "$DIR"

echo "Generating playground..."
python3 test.py

if [ "$MODE" == "monarch" ]; then
    echo "Openning Monarch Playground template..."
    python3 -m webbrowser -t "file://$DIR/monarch.patched.ts"
    python3 -m webbrowser -t "https://microsoft.github.io/monaco-editor/playground.html"
else
    echo "Openning in a web-browser..."
    python3 -m webbrowser -t "file://$DIR/test.patched.html?syntax=$MODE&theme=$THEME"
fi