aboutsummaryrefslogtreecommitdiff
path: root/tests/init.test
blob: 43ce441956a9fd3deb30138dfb32465046ec221f (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
# file      : tests/init.test
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

# Here we test both init and deinit commands.
#

.include common.test project.test

new    += 2>!
status += --all
deinit += -d prj

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

: cfg-create
:
: We will also test that the configuration variables are properly persisted and
: the project is properly built in the source tree.
:
{
  $clone_prj;

  $* -C @cfg $cxx 'config.cc.poptions=-DTEST' 2>>/~"%EOE%" &prj-cfg/***;
    initializing in project $~/prj/
    created configuration @cfg $~/prj-cfg/ \(1, default, forwarded, auto-synchronized\)
    synchronizing:
    %  new prj.0\.1\.0-a\.0\.19700101000000%
    EOE

  sed -n -e 's/^config.cc.poptions = (.+)$/\1/p' prj-cfg/build/config.build \
    >'-DTEST';

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

  $build prj/ 2>>/EOE &prj/prj/prj$exe;
    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

  $build prj-cfg/ 2>>/EOE;
    info: dir{prj-cfg/} is up to date
    EOE

  $deinit 2>>/"EOE"
    deinitializing in project $~/prj/
    synchronizing:
      drop prj
    EOE
}

: cfg-add
:
{
  create_cfg = $bpkg create $cxx -d 2>!

  $clone_prj;

  $create_cfg prj-cfg1/ &prj-cfg1/***;
  $create_cfg prj-cfg2/ &prj-cfg2/***;

  $* -A @cfg1 2>>/~"%EOE%";
    initializing in project $~/prj/
    added configuration @cfg1 $~/prj-cfg1/ \(1, default, forwarded, auto-synchronized\)
    synchronizing:
    %  new prj.0\.1\.0-a\.0\.19700101000000%
    EOE

  $* -A prj-cfg2 @cfg2 2>>/~"%EOE%";
    initializing in project $~/prj/
    added configuration @cfg2 $~/prj-cfg2/ \(2, auto-synchronized\)
    synchronizing:
    %  new prj.0\.1\.0-a\.0\.19700101000000%
    EOE

  $status --directory prj >>EOO;
    in configuration @cfg1:
    prj configured 0.1.0-a.0.19700101000000

    in configuration @cfg2:
    prj configured 0.1.0-a.0.19700101000000
    EOO

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

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

  $build prj/ 2>>/EOE &prj/prj/prj$exe;
    ln prj-cfg1/prj/prj/exe{prj} -> prj/prj/
    info: prj-cfg1/dir{prj/} is up to date
    EOE

  $deinit 2>>/"EOE"
    deinitializing in project $~/prj/
    synchronizing:
      drop prj
    EOE
}

# @@ Test initializing a package rather than project.
#