aboutsummaryrefslogtreecommitdiff
path: root/tests/new.test
blob: 99292b92c1038c4d782eb7a8aea948600686c111 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# file      : tests/new.test
# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

.include common.test

cxx = "config.cxx=$config.cxx"

status += -d prj

: exe
{
  $* -t exe -l c++ prj 2>>/"EOE" &prj/***;
    created new executable project prj in $~/prj/
    EOE

  $build prj/ $cxx 2>>/EOE
    c++ prj/prj/cxx{prj}
    ld prj/prj/exe{prj}
    EOE
}

: lib
{
  $* -t lib -l c++ libprj 2>>/"EOE" &libprj/***;
    created new library project libprj in $~/libprj/
    EOE

  $build libprj/ $cxx 2>>/~%EOE%
    %.{4}
    %ld libprj/.+%{3}
    EOE
}

: pkg
:
{
  : add
  :
  : Test creating a library as a separate package in the project.
  :
  {
    $* -t empty prj 2>>/"EOE" &prj/***;
      created new empty project prj in $~/prj/
      EOE

    $* --package -t lib libprj -d prj 2>>/"EOE";
      created new library package libprj in $~/prj/libprj/
      EOE

    $build prj/libprj/ $cxx 2>>/~%EOE%
      %.{4}
      %ld prj/libprj/.+%{3}
      EOE
  }

  : name
  :
  : Test that the package name is validated.
  :
  {
    : project
    :
    $* x 2>'error: invalid package name: length is less than two characters' != 0

    : separate
    :
    : Here we also test that the project name is not validated as a package.
    :
    {
      $* -t empty x 2>>/"EOE" &x/***;
        created new empty project x in $~/x/
        EOE

      $* --package y -d x 2>'error: invalid package name: length is less than two characters' != 0
    }
  }
}

: cfg
{
  : dir-and-name
  :
  {
    $* -C prj-config @cfg prj cc $cxx 2>>/~"%EOE%" &prj/*** &prj-config/***;
      created new executable project prj in $~/prj/
      created configuration @cfg $~/prj-config/ \(1, default, forwarded, auto-synchronized\)
      synchronizing:
      %  new prj.+19700101000000%
      EOE

    $status >'prj configured 0.1.0-a.0.19700101000000';

    $build prj/ 2>>/EOE
      mkdir prj-config/prj/fsdir{prj/}
      c++ prj/prj/cxx{prj}@prj-config/prj/prj/
      ld prj-config/prj/prj/exe{prj}
      ln prj-config/prj/prj/exe{prj} -> prj/prj/
      EOE
  }

  : name
  :
  : Test deducing the configuration directory path from the project source
  : directory path and the configuration name. Here we also use the
  : dash-prefixed name (as in Windows PowerShell where the leading '@'
  : character is special).
  :
  {
    $* -C -@cfg prj cc $cxx 2>>/~"%EOE%" &prj/*** &prj-cfg/***;
      created new executable project prj in $~/prj/
      created configuration @cfg $~/prj-cfg/ \(1, default, forwarded, auto-synchronized\)
      synchronizing:
      %  new prj.+19700101000000%
      EOE

    $status >'prj configured 0.1.0-a.0.19700101000000';

    $build prj/ 2>>/EOE
      mkdir prj-cfg/prj/fsdir{prj/}
      c++ prj/prj/cxx{prj}@prj-cfg/prj/prj/
      ld prj-cfg/prj/prj/exe{prj}
      ln prj-cfg/prj/prj/exe{prj} -> prj/prj/
      EOE
  }
}