summaryrefslogtreecommitdiffhomepage
path: root/tests/cram/test_basic.t
blob: 3d4cd9e1faab14012b41197a3028ac64555e9446 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
setup common environment:

  $ [ -n "$BUILD_BIN_DIR" ] && export PATH="$BUILD_BIN_DIR:$PATH"
  $ alias ucode="$UCODE_BIN"

  $ for m in $BUILD_BIN_DIR/*.so; do
  >   ln -s "$m" "$(pwd)/$(basename $m)"; \
  > done

check that ucode provides exepected help:

  $ ucode | sed 's/ucode-san/ucode/'
  == Usage ==
  
    # ucode [-d] [-l] [-r] [-S] [-e '[prefix=]{"var": ...}'] [-E [prefix=]env.json] {-i <file> | -s "ucode script..."}
    -h, --help\tPrint this help (esc)
    -i file\tSpecify an ucode script to parse (esc)
    -s "ucode script..."\tSpecify an ucode fragment to parse (esc)
    -d Instead of executing the script, dump the resulting AST as dot
    -l Do not strip leading block whitespace
    -r Do not trim trailing block newlines
    -S Enable strict mode
    -e Set global variables from given JSON object
    -E Set global variables from given JSON file
    -m Preload given module

check that ucode prints greetings:

  $ ucode -s "{% print('hello world') %}"
  hello world (no-eol)

check that ucode provides proper error messages:

  $ ucode -m foo
  One of -i or -s is required
  [1]

  $ ucode -m foo -s ' '
  Runtime error: No module named 'foo' could be found
  At start of program
  
  [1]

  $ touch moo; ucode -m foo -i moo
  Runtime error: No module named 'foo' could be found
  At start of program
  
  [1]

check that ucode can load fs module:

  $ ucode -m fs
  One of -i or -s is required
  [1]

  $ ucode -m fs -s ' '
    (no-eol)

  $ touch moo; ucode -m fs -i moo