I am a total noob with ant but more or less I have an idea about how it works. I have come across a situation that I fail to understand and I would appreciate any help.
This is going to be a bit long, sorry. I am trying to make it as clear as possible.
I have a set of targets that works like this : I will use "-" as substitute of "depends" :
- B - D - E - E1 - E2 unless property2 - E3 If property3 - E4 unless property4 - E5 - E6
doc-contracts
- C - E - E1 - E2 unless property2 - E3 If property3 - E4 unless property4 - E5 - E6
Just in case it is a bit confusing, "doc-contracts" depends on B and C and both paths end up calling target E.
This is the code of "doc-contracts" :
<target
name="doc-contracts"
depends="B,C"
description="Generates the documentation for contracts and annotations"
>
<foreach
target="doc-contracts-single"
param="doc-contracts-single.file"
inheritall="true"
>
<path>
<fileset dir="${properties.src.dir}">
<include name="*/*.csv"/>
</fileset>
</path>
</foreach>
</target>
Basically, for each csv it will call the target "doc-contracts-single". "doc-contracts-single" needs a path reference "pathReference" that is set inside target E.
The thing is that, when I run "doc-contracts" I get this output:
E6
E5
E4
E2
E1
E
D
B
C
doc-contracts
doc-contracts-single
ERROR: Reference pathReference has not been set at runtime, but was found during build file parsing, attempting to resolve. Future versions of Ant may
support referencing ids defined in non-executed targets.
doc-contracts-single
ERROR: Reference pathReference has not been set at runtime, but was found during build file parsing, attempting to resolve. Future versions of Ant may
support referencing ids defined in non-executed targets.
END
I have 2 questions:
As you can see, it only goes through E one time and I don't know why. I can understand that, once the first "branch" (B and all its tree of dependencies) the flow
could be interrupted in E2 if property2 is set (which I am pretty sure, it is what is happening). But then the code should at least go through E and E1 again since those 2
tasks doesn't have any condition, isn't it?. I have put echoes in all targets and it simply won't go inside targets E and E1. Under my understanding I should be getting this output:
E6
E5
E4
E2
E1
E
D
B (end of "first branch", which would be B and the chain of targets it generates)
E1
E
C (end of "first branch", which would be B and the chain of targets it generates)
doc-contracts
doc-contracts-single
ERROR: Reference pathReference has not been set at runtime, but was found during build file parsing, attempting to resolve. Future versions of Ant may
support referencing ids defined in non-executed targets.
doc-contracts-single
ERROR: Reference pathReference has not been set at runtime, but was found during build file parsing, attempting to resolve. Future versions of Ant may
support referencing ids defined in non-executed targets.
... (once for each .csv it finds)
END
Is this correct? Am I missunderstanding how ant flow works?
As I said before, the error I get when doc-contracts-single is executed is the following:
With ant 1.7 -> Reference pathReference has not been set at runtime, but was found during build file parsing, attempting to resolve. Future versions of Ant may
support referencing ids defined in non-executed targets.
With ant 1.9 -> Error as expected from the message in ant 1.7
I have echoed the content of "pathReference" and it looks fine and well defined until target "doc-contracts" calls "doc-contracts-single". Inside "doc-contracts-single"
the reference is lost. Can anyone explain to me why? I thought that when you set a path reference in your project, it could be used at any point in the rest
of the project. I can only think about 2 options:
1- Either some part of the script is deleting it's content, and I can't find which line is doing this
or
2- Because "doc-contracts" and "doc-contracts-single" are not related with "depends" (instead, one calls the other), they are in different scopes and the references set with one are not visible
from the other.
Sorry for such a long post. I have tried my best to explain the problem as clear as possible. Thanks in advance for your answers!
Related
As I'm new to cobol, please help me with the below piece of code.
WORKING-STORAGE SECTION.
01 BAS-REC.
02 INPT-REC.
49 INPT-LEN PIC S9(4) COMP.
49 INPT-TEXT PIC X(150).
02 INPT1-REC.
49 INPT1-LEN PIC S9(4) COMP.
49 INPT1-TEXT PIC X(150).
02 INPT2-REC.
49 INPT2-LEN PIC S9(4) COMP.
49 INPT2-TEXT PIC X(150).
77 VAR1 PIC X(5) VALUE 'APT'.
77 NUM1 PIC 9(1).
I'm using the level 49 for character varying here (to truncate trailing spaces)
Then I have cursor fetch.
After few modification under PROCEDURE DIVISION I'm doing the below.
PERFORM UNTIL SQLCODE=100
PERFORM VARYING NUM1 FROM 1 BY 1 UNTIL NUM1=6
STRING INPT-REC DELIMITED BY ' ',' ',
VAR1 DELIMITED BY ' ',' '
NUM1 DELIMITED BY ' ' INTO INPT2-REC
EXEC SQL
insert query here (which will run 5 times)
END-EXEC
END- PERFORM
END- PERFORM
but in the table the data got inserted only once but it shold have got inserted 5 times and also the INPT2-REC hasn't been concatenated. The INPT2 -REC just contains the value of INPT-REC alone
My question is this a special characteristic of level 49 or am I wrong somewhere?
Note that if you use INPT-REC2 as a host-variable for a VARCHAR-field you will only see the part from INPT-REC since you never update the length-field: it still contains the length it was assigned from INPT-REC.
So you'll have to somehow get the actual length of INPT2-TEXT (e.g. INSPECT the REVERSE of INPT2-TEXT for LEADING SPACES) and move it to INPT2-LENGTH before your EXEC SQL.
As I already said in my comment: there is nothing special about level 49 - you could as well use 48, 33,30 or 05 with the same results. The samples in the DB2 manual probably use 49 since it is the last valid level-number without any special meaning, so it is least likely to cause problems with any level-numbers already used in the program.
As for the query being executed only once: in your loop you are varying NUM1 but are checking whether I=6 - since we don't see I anywhere in your example I can only guess that it is already equal to 6 upon entering the loop.
Level 49 can be treated specially when Embedded SQL is involved, depending on system; this text is copied from the IBM Knowledge Center
Host structure declarations in COBOL must satisfy the following requirements:
COBOL host structures can have a maximum of two levels, even though the host structure might occur within a structure with multiple levels. However, you can declare a varying-length character string, which must be level 49.
A host structure name can be a group name whose subordinate levels name elementary data items.
If you are using the DB2® precompiler, do not declare host variables or host structures on any subordinate levels after one of the following items:
A COBOL item that begins in area A
Any SQL statement (except SQL INCLUDE)
Any SQL statement within an included member
When the DB2 precompiler encounters one of the preceding items in a host structure, it considers the structure to be complete.
So, this seems like a little implementation detail (level 49 for var char) that may spill over into other implementations of COBOL ESQL. Like many details buried in systems, Knowing that would require knowing that.
This particular detail is news to me as of a few minutes ago.
Looking more just now, this came up in the esqlOC contribution for GnuCOBOL recently. A level 49 specific tweak to ensure there was no need to worry about little end big end storage between host and service. So it seems to be a thing.
And an answer to the original question is; depends on compiler environment and ESQL preprocessor, but yeah maybe level 49 fields can be used for VARCHAR.
01 ws-var-05 pic x value 'n'.
88 ws-var-88 value 'y'
01 ws-var-2 pic 9 value 1.
88 ws-var-88-2 value 2.
.
.
.
* comment ws-var-88-2 is set to true when eof is
* reached in the at end clause of read statement
* need to understand when ws-var-05 evaluates to
* true! Is this right syntax? What happens if we use
* this syntax? Need to understand if this is a
* defect
Perform 1000-para until ws-var-88-2 or ws-var-05.
The line...
Perform 1000-para until ws-var-88-2 or ws-var-05.
...contains a syntax error, at least when compiled with GNU COBOL 1.1.0.
The UNTIL clause of the PERFORM verb can contain conditional expressions. One type of conditional expression is a "condition-name condition" which is an 88-level. However, the name of an identifier (in this case ws-var-05) must be followed by a conditional operator (<, >, =, etc.) and then either another identifier or a literal for the UNTIL clause to be valid.
Is this right syntax?
No.
What happens if we use this syntax?
A compile-time error will occur.
Several things.
It is very much a "best practice" to leave the storage that backs your conditional items (88s) unnamed. This prevents people from accidentally moving the wrong value into them and causing subtle bugs.
For example, this:
01 ws-var-05 pic x value 'n'.
88 ws-var-88 value 'y'
01 ws-var-2 pic 9 value 1.
88 ws-var-88-2 value 2.
Is better written as this:
01 pic x value 'n'.
88 ws-var-88 value 'y'.
01 pic 9 value 1.
88 ws-var-88-2 value 2.
So nobody can ever accidentally do a "Move 'Y' to ws-var-05". This is especially problematic on mainframes, where there are some automatic uppercasing editor options that could really make the difference between 'y' and 'Y' hard to notice.
In the case of this, there are several things, the ws-var-05 is not a complete conditional, you could use "ws-var-88 or ws-var-88-2" and it would be a complete conditional.
You don't need a period at the end, and its use can often be problematic with modern compilers. Since Cobol-85, the END-verbname is the preferred way to terminate a command. You could write this:
Perform 1000-para until ws-var-88-2 or ws-var-05.
as:
Perform 1000-para until (ws-var-88 or ws-var-88-2)
or, IMNSHO, a clearer and cleaner approach, as it separates your terminate condition from the commands you will be executing in the body of the perform:
Perform until (ws-var-88-2 or ws-var-88-2)
Perform 1000-para
End-Perform
I will also always use parens to delimit my intended order of operations, though in this case, it matters not. For more complicated conditions, they can be a big help for the on-call programmer that has to look at something blowing up at 3am.
You trigger your terminal conditionals like so:
1000-para.
Read myfile
at end
set ws-var-88-2 to true
End-Read
If (something-else = time-to-quit)
set ws-var-88 to true
End-If
Exit. *> One of the few places you need a period
*> in modern cobol, adding the "Exit" or
*> "Continue" NOPs clearly calls out to a
*> reader that you are using a period.
I'm using the smt2-lib interface of z3 and trying to define the following:
(declare-const rem (set sl$REQ))
And get this error:
(error "line 36 column 31: invalid declaration, builtin symbol rem")
Is there a way to get a complete list of all the predefined symbols so that I can do an automatic renaming?
Thanks!
Simon
Yes, but it's not quite that trivial. Depending on options and logic definitions, the list of pre-defined symbols may change. But, you can get a list of all potentially predefined symbols by grepping for builtin_name in src/ast/*_decl_plugin.cpp. For example, the rem symbol is defined at arith_decl_plugin.cpp:540.
I'm coding a unit test where a (rather lengthy) binary is generated, and I want to assert that the generated binary equals the one I expect to be generated. I'm running eunit through "rebar eunit".
Thing is, when this assertion fails, the output is abreviated with "...", and I want to see the complete output so I can spot where the difference is.
I'm now using "?debugFmt()" as a temporary solution, but I'd like to know if there's an alternative to it (a config option or argument somewhere that can be applied to "?_assertEqual()" so the output is only shown when the assertion fails).
Thanks in advance!
EDIT: Due to legoscia's answer, I'm including a test sample using a test generator, with multiple asserts:
can_do_something(SetupData) ->
% ... some code ...
[?_assertEqual(Expected1, Actual1), ?_assertEqual(Expected2, Actual2)].
The best I can think of for actually showing the value in the console is something like this:
Actual =:= Expected orelse ?assert(?debugFmt("~p is not ~p", [Actual, Expected]))
?debugFmt returns ok, which is not true, so the assertion will always fail.
Alternatively, to use it as a test generator, the entire thing can be put inside ?_assert:
?_assert(Actual =:= Expected orelse ?debugFmt("~p is not ~p", [Actual, Expected]))
The way I usually achieve this is by having Eunit output XML files (in "Surefire" format, AKA "Junit" format). The XML files have much higher limits for term print depth, and thus probably contain the information you need.
Add this to your rebar.config:
{eunit_opts,
[verbose,
%% eunit truncates output from tests - capture full output in
%% XML files in .eunit
{report,{eunit_surefire,[{dir,"."}]}}]}.
Then you can find the results for module foo in .eunit/TEST-foo.xml. I find the files quite readable in a text editor.
1). Open your eunit sources. In my system:
cd /usr/lib/erlang/lib/eunit-2.3.2/src
2). Edit eunit_lib.erl in such way:
diff
54c54
< format_exception(Exception, 20).
---
> format_exception(Exception, 99999).
3). sudo erlc -I ../include eunit_lib.erl
4). mv eunit_lib.beam ../ebin
5). Have a good day))
This PR introduces print_depth option to eunit:test/2:
eunit:test(my_test, [{print_depth, 200}]).
It should be available starting from OTP-23.
Setting print_depth to a larger number will decrease truncation of the output.
I'm trying to make an Ant target that runs if ONE of two other targets completes. Basically, assuming I have three targets A1, A2, and B, I want B to run only if A1 OR A2 run. A1 and A2 depend on a condition, so either A1 or A2 will run (but never both).
For example:
<target name="A1" if="${conditionalVar}">
<target name="A2" unless="${conditionalVar}">
<target name="B" depends="????????">
What should the 'depends' for target B be? Is there anyway to do this?
Yes, such a configuration is possible and not very complicated:
The trick is to set a property that will be tested if set (e.g. call it "taskA1.use").
<target name="A1" if="taskA1.use" />
<target name="A2" unless="taskA1.use" />
<target name="B" depends="A1,A2" />
Therefore even if B depends on both tasks A1 and A2 only one will be executed depending of the property "taskA1.use" has been set or not.