cobalto 0.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. cobalto-0.8.0/LICENSE +202 -0
  2. cobalto-0.8.0/PKG-INFO +209 -0
  3. cobalto-0.8.0/README.md +187 -0
  4. cobalto-0.8.0/pyproject.toml +43 -0
  5. cobalto-0.8.0/setup.cfg +4 -0
  6. cobalto-0.8.0/src/cobalto/__init__.py +3 -0
  7. cobalto-0.8.0/src/cobalto/__main__.py +6 -0
  8. cobalto-0.8.0/src/cobalto/build.py +164 -0
  9. cobalto-0.8.0/src/cobalto/cli.py +148 -0
  10. cobalto-0.8.0/src/cobalto/cobolgen.py +50 -0
  11. cobalto-0.8.0/src/cobalto/cobparse.py +1039 -0
  12. cobalto-0.8.0/src/cobalto/commands.py +464 -0
  13. cobalto-0.8.0/src/cobalto/condcov.py +337 -0
  14. cobalto-0.8.0/src/cobalto/config.py +93 -0
  15. cobalto-0.8.0/src/cobalto/coverage.py +678 -0
  16. cobalto-0.8.0/src/cobalto/debuginfo.py +280 -0
  17. cobalto-0.8.0/src/cobalto/driver.py +105 -0
  18. cobalto-0.8.0/src/cobalto/dsl.py +360 -0
  19. cobalto-0.8.0/src/cobalto/inprog.py +1059 -0
  20. cobalto-0.8.0/src/cobalto/lib/CBLTCTX.cpy +23 -0
  21. cobalto-0.8.0/src/cobalto/lib/CBLTLIB.cbl +404 -0
  22. cobalto-0.8.0/src/cobalto/messages.py +95 -0
  23. cobalto-0.8.0/src/cobalto/model.py +30 -0
  24. cobalto-0.8.0/src/cobalto/pad80.py +68 -0
  25. cobalto-0.8.0/src/cobalto/profiles/gnucobol-coverage.json +11 -0
  26. cobalto-0.8.0/src/cobalto/profiles/gnucobol-debug.json +8 -0
  27. cobalto-0.8.0/src/cobalto/profiles/gnucobol-ibm.json +8 -0
  28. cobalto-0.8.0/src/cobalto/profiles/gnucobol-mf.json +8 -0
  29. cobalto-0.8.0/src/cobalto/profiles/gnucobol.json +8 -0
  30. cobalto-0.8.0/src/cobalto/profiles/microfocus.json +8 -0
  31. cobalto-0.8.0/src/cobalto/profiles/remote-sim.build.sh +5 -0
  32. cobalto-0.8.0/src/cobalto/profiles/remote-sim.json +26 -0
  33. cobalto-0.8.0/src/cobalto/profiles/remote-sim.run.sh +4 -0
  34. cobalto-0.8.0/src/cobalto/profiles/vms-vsi-cobol.build.com +59 -0
  35. cobalto-0.8.0/src/cobalto/profiles/vms-vsi-cobol.json +33 -0
  36. cobalto-0.8.0/src/cobalto/profiles/vms-vsi-cobol.run.com +11 -0
  37. cobalto-0.8.0/src/cobalto/remote.py +216 -0
  38. cobalto-0.8.0/src/cobalto/reports.py +218 -0
  39. cobalto-0.8.0/src/cobalto/results.py +182 -0
  40. cobalto-0.8.0/src/cobalto/runner.py +88 -0
  41. cobalto-0.8.0/src/cobalto/suggest.py +454 -0
  42. cobalto-0.8.0/src/cobalto.egg-info/PKG-INFO +209 -0
  43. cobalto-0.8.0/src/cobalto.egg-info/SOURCES.txt +44 -0
  44. cobalto-0.8.0/src/cobalto.egg-info/dependency_links.txt +1 -0
  45. cobalto-0.8.0/src/cobalto.egg-info/entry_points.txt +3 -0
  46. cobalto-0.8.0/src/cobalto.egg-info/top_level.txt +1 -0
cobalto-0.8.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
cobalto-0.8.0/PKG-INFO ADDED
@@ -0,0 +1,209 @@
1
+ Metadata-Version: 2.4
2
+ Name: cobalto
3
+ Version: 0.8.0
4
+ Summary: Portable unit testing for COBOL
5
+ Author: Fabian Baptista, Abstracta
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/abstracta/cobalto
8
+ Project-URL: Documentation, https://github.com/abstracta/cobalto/blob/main/docs/reference.md
9
+ Project-URL: Issues, https://github.com/abstracta/cobalto/issues
10
+ Project-URL: Changelog, https://github.com/abstracta/cobalto/blob/main/CHANGELOG.md
11
+ Keywords: cobol,unit-testing,testing,legacy,gnucobol,openvms
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Software Development :: Testing
17
+ Classifier: Topic :: Software Development :: Testing :: Unit
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Dynamic: license-file
22
+
23
+ <p align="center"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/abstracta/cobalto/v0.8.0/docs/logo/cobalto-logo-white.svg"><img src="https://raw.githubusercontent.com/abstracta/cobalto/v0.8.0/docs/logo/cobalto-logo.svg" alt="Cobalto" width="360"></picture></p>
24
+
25
+ # Cobalto
26
+
27
+ **Unit testing for COBOL that runs wherever your COBOL runs.**
28
+
29
+ Cobalto lets a team test, debug and understand its COBOL with the compiler it already has: no new licenses and no vendor lock-in. Tests are written in a small language that reads like COBOL and run from the command line or from VS Code, where a suite can also be debugged in COBOL terms, with the program's own statements and data names. Results come out in JUnit, LCOV, Cobertura XML and SonarQube's generic format, so they fit into an existing CI pipeline, and an AI model can propose a first draft of a suite for a person to review.
30
+
31
+ It is an open source project by [Abstracta](https://abstracta.us), created by Fabian Baptista and released under Apache-2.0.
32
+
33
+ ![Cobalto in VS Code: a failing test case, a debugging session that steps into the program down to the defect, the fix, and the suites passing with coverage](https://raw.githubusercontent.com/abstracta/cobalto/v0.8.0/vscode-cobalto/images/demo.gif)
34
+
35
+ ## Why
36
+
37
+ COBOL systems run critical processes in banks, insurers, government agencies and utilities, and the teams that maintain them change business logic with no tests to tell them when something breaks. The unit testing tools that exist for COBOL are tied to one compiler, one platform or one license, or are no longer maintained. For many teams the alternative is not another tool but no unit tests at all.
38
+
39
+ Cobalto gives a program a suite that does not depend on where it is compiled: the part that runs inside the COBOL is standard COBOL 85, and everything specific to an environment lives in a profile. GnuCOBOL shows the value of this on a single machine: the same suite compiled with the IBM or the Micro Focus dialect catches behavior that changes with the compiler, such as rounding, binary field sizes and truncation.
40
+
41
+ Cobalto is not a migration tool: it does not translate, convert or move code. A migration is one of the changes a suite makes safer, along with everyday maintenance, refactoring and a change of compiler or dialect. It is also the one where a portable suite pays off most, because the same tests run before and after.
42
+
43
+ ## How it works
44
+
45
+ - **Portable core.** The assertions, the test context and the driver that runs the suites are plain COBOL 85, fixed format, with no extensions.
46
+ - **One profile per environment.** How to compile, link and run, where the results file goes, and whether the build happens on another machine over ssh, all live in a declarative profile. Adding a compiler means writing a profile, not touching the core.
47
+ - **A CLI with no dependencies.** Python 3, standard library only. It discovers the suites, generates the test COBOL, compiles, runs, reads the results and writes the console output and the reports. It works on any machine with Python, with or without internet access.
48
+ - **A VS Code extension.** Test Explorer, coverage in the gutter and debugging in COBOL terms (breakpoints in the suite, stepping by statement, conditions written in COBOL, changing values) on top of the same project and the same CLI.
49
+
50
+ ## What you can test
51
+
52
+ **Whole programs.** A suite describes test cases that call the program under test through its interface (`CALL ... USING`) and check the results with readable assertions:
53
+
54
+ ```cobol
55
+ TESTSUITE TSTDISC 'Discounts by amount'
56
+
57
+ WORKING-STORAGE SECTION.
58
+ 01 WS-AMOUNT PIC 9(7)V99.
59
+ 01 WS-RESULT PIC 9(7)V99.
60
+ 01 WS-CATEGORY PIC X(10).
61
+
62
+ TESTCASE 'premium amount gets 20%'
63
+ MOVE 2000 TO WS-AMOUNT
64
+ CALL "DISCOUNT" USING WS-AMOUNT WS-RESULT WS-CATEGORY
65
+ EXPECT WS-RESULT TO BE NUMERIC 1600
66
+ EXPECT WS-CATEGORY TO BE 'PREMIUM'
67
+ ```
68
+
69
+ **Single paragraphs of a program, without refactoring it.** With in-program mode, Cobalto injects the suite into a copy of the program. Test cases can `PERFORM` any paragraph, read and set any `WORKING-STORAGE` field, and replace, one test case at a time, calls to other programs, file access, embedded SQL and the system date. `RUN` executes the original flow from its entry point, with the program's `STOP RUN` ending the test case instead of the process:
70
+
71
+ ```cobol
72
+ TESTSUITE TSTINV 'Invoicing (in-program on INVOICE)'
73
+ PROGRAM INVOICE
74
+
75
+ TESTCASE 'full process with mocked files'
76
+ MOCK FILE CUST-FILE
77
+ ON READ
78
+ EVALUATE CBLT-READ-COUNT
79
+ WHEN 1
80
+ MOVE "C001ACME 000200000" TO CUST-REC
81
+ WHEN OTHER
82
+ SET CBLT-AT-END TO TRUE
83
+ END-EVALUATE
84
+ END-MOCK
85
+ PERFORM 2000-PROCESS
86
+ EXPECT WS-TOTAL TO BE NUMERIC 1600
87
+ VERIFY CALL 'DISCOUNT' HAPPENED ONCE
88
+ VERIFY PARAGRAPH 3000-END NEVER HAPPENED
89
+ ```
90
+
91
+ A mock applies only to the test case that declares it. Every other test case runs the original code.
92
+
93
+ **Interface and internal cases.** The report marks each test case as an *interface* case, which only looks at what goes into the program and what comes out, or an *internal* case, which runs a paragraph or looks at the program's own fields. Interface cases are the ones that still make sense after the program is rewritten or translated.
94
+
95
+ **Coverage with any compiler.** With `--coverage`, the CLI instruments a copy of each program under test and measures statements, the branches of `IF`, `EVALUATE` and `SEARCH`, compound conditions by operand, and paragraphs, without gcov or a special runtime. The result goes to the console and to LCOV, Cobertura XML and SonarQube's generic format.
96
+
97
+ **Results as data.** `cobalto test --json` writes the whole run as JSON: totals, every test case, the expected and actual value of each assert and, with `--coverage`, coverage. The same model is saved to `build/results.json`, so a script never has to read console text. [Using Cobalto from a coding agent](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/coding-agents.md) covers the Claude Code skill, the loop it follows and which of these outputs an agent can rely on.
98
+
99
+ **A draft suite proposed by AI.** `cobalto suggest` asks a model for a suite for a program, compiles it, runs it with coverage and feeds back what failed or was left uncovered, in rounds. The result is a draft of characterization tests for a person to review, and everything sent to the provider is kept in `build/ai/`.
100
+
101
+ ## Status
102
+
103
+ What exists today, and how far each part has been verified:
104
+
105
+ | Capability | Verification |
106
+ |---|---|
107
+ | COBOL 85 core (assertions, context, driver) | `cobc -fsyntax-only` with no errors or warnings in the eight strict dialects of GnuCOBOL. Compiled, linked and run with VSI COBOL on OpenVMS |
108
+ | External and in-program suites, with mocks per test case (paragraphs, `CALL`, files, `EXEC SQL`, clock) | GnuCOBOL 3.2 on the seven example programs: 105 test cases, 415 asserts, 2 intentional failures, 6 skipped. 46 interface cases and 58 internal ones; the one test written in plain COBOL, without the DSL, is not classified. The SQL mock is not verified with a real precompiler |
109
+ | Portable coverage by statement, branch, condition and paragraph | GnuCOBOL 3.2. The Sonar report was checked with SonarQube Community; Sonar's COBOL analyzer (Enterprise edition) was not tried |
110
+ | The same suite across dialects: profiles `gnucobol-ibm` and `gnucobol-mf` | With `-std=ibm` five more test cases fail and with `-std=mf` two more, because of rounding and the size and truncation of binary fields |
111
+ | VS Code extension | macOS with GnuCOBOL 3.2, lldb-dap from Xcode and VS Code 1.147. On Linux, the debug adapter was verified over the protocol in a container |
112
+ | AI-assisted drafts (`cobalto suggest`) | Claude on three of the example programs: 36 test cases proposed in two rounds, all passing |
113
+ | Remote profiles (build and run on another machine) | The ssh mechanics are verified with a local simulator, where two test cases that use an indexed file still fail. For hosts without ssh, `cobalto report` reads a results file and a screen capture brought back by hand |
114
+
115
+ | Compiler | Status |
116
+ |---|---|
117
+ | GnuCOBOL 3.x on Linux and macOS | Verified |
118
+ | VSI COBOL V3.1-0007 on OpenVMS V8.4-2L3 | Verified with the generated DCL scripts run by hand and the results read by `cobalto report`. The generated build script was edited after that run (its labels were renamed) and has not been run on OpenVMS again. Automation over ssh is not verified |
119
+ | Micro Focus | Profile template only. Not verified |
120
+ | IBM Enterprise COBOL | No profile yet. Not verified |
121
+
122
+ Running on any compiler that follows the standard is the design goal. The table above is what has been checked.
123
+
124
+ ## Roadmap
125
+
126
+ The first release is 0.8.0, on PyPI, and every release is listed in the [changelog](https://github.com/abstracta/cobalto/blob/v0.8.0/CHANGELOG.md). Until 1.0, the CLI, the suite language and the file formats can still change. This is what is missing to get there:
127
+
128
+ | Area | Today | Needed for 1.0 |
129
+ |---|---|---|
130
+ | Compilers | GnuCOBOL and VSI COBOL verified | Micro Focus and IBM Enterprise COBOL verified with a real run |
131
+ | Remote builds | The ssh mechanics run against a local simulator | A build and a run over ssh on a real host |
132
+ | SQL mock | Covered by Cobalto's own tests, never run through a precompiler | Verified with a real precompiler |
133
+ | Free-format sources | Parsed; in-program mode not verified with a compiler | In-program mode verified on a free-format program |
134
+ | VS Code extension | On the Marketplace and Open VSX. Verified on macOS; on Linux, only the debug adapter | Verified end to end on Linux |
135
+ | Windows | Not tried | Verified, or documented as not supported |
136
+ | Stability | Interfaces can change between minor versions, and every change is listed in the changelog | The CLI, the suite language and the results format frozen and versioned |
137
+
138
+ The compiler rows are the ones where outside help counts most: see [Adding a compiler](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/adding-a-compiler.md).
139
+
140
+ ## Try it
141
+
142
+ You need Python 3.9 or later and GnuCOBOL 3.x (`brew install gnucobol` on macOS, the `gnucobol3` package on Debian and Ubuntu). Install the CLI from PyPI, in a virtual environment; it adds the `cobalto` command and its short alias `cblt`:
143
+
144
+ ```bash
145
+ python3 -m venv .venv
146
+ source .venv/bin/activate
147
+ python3 -m pip install cobalto
148
+ ```
149
+
150
+ The virtual environment keeps the install out of the system Python, which Homebrew and recent Debian and Ubuntu do not let `pip` modify. The command is available while the environment is active.
151
+
152
+ The example project is in this repository. Clone it and run its suites:
153
+
154
+ ```bash
155
+ git clone https://github.com/abstracta/cobalto.git
156
+ cd cobalto/examples
157
+ ```
158
+
159
+ ```bash
160
+ cobalto test --coverage
161
+ ```
162
+
163
+ ```bash
164
+ cobalto test --profile gnucobol-ibm
165
+ ```
166
+
167
+ ```bash
168
+ cobalto test --json
169
+ ```
170
+
171
+ The example project includes two test cases that fail on purpose, so these commands end with exit code 1.
172
+
173
+ To start a project of your own:
174
+
175
+ ```bash
176
+ cobalto init /path/to/my/project
177
+ ```
178
+
179
+ To install from a clone instead, for example to try a change that is not released yet, run `python3 -m pip install .` from the root of the clone, in a virtual environment.
180
+
181
+ To write a first suite step by step, see [First suite in 15 minutes](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/reference.md#first-suite-in-15-minutes) in the reference. The VS Code extension is `abstracta.vscode-cobalto`, on the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=abstracta.vscode-cobalto) and on [Open VSX](https://open-vsx.org/extension/abstracta/vscode-cobalto); see [its README](https://github.com/abstracta/cobalto/blob/v0.8.0/vscode-cobalto/README.md).
182
+
183
+ ## Where things are
184
+
185
+ | Path | What it is |
186
+ |---|---|
187
+ | [src/cobalto/](https://github.com/abstracta/cobalto/tree/v0.8.0/src/cobalto/) | The tool, as a Python package: the CLI, the COBOL core (`lib/`) and the built-in profiles (`profiles/`) |
188
+ | [examples/](https://github.com/abstracta/cobalto/tree/v0.8.0/examples/) | The example project: seven programs (`src/`), their suites (`tests/`) and its `cblt.json` |
189
+ | [docs/reference.md](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/reference.md) | The reference for the DSL, the project file, profiles, coverage, debugging and AI-assisted drafts |
190
+ | [docs/design.md](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/design.md) | How Cobalto is built and why: the portable core, the results protocol, in-program mode, coverage, and the limits of each |
191
+ | [docs/adding-a-compiler.md](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/adding-a-compiler.md) | How to try Cobalto with another compiler and contribute its profile |
192
+ | [docs/coding-agents.md](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/coding-agents.md) | Using Cobalto from a coding agent: the Claude Code skill, its loop and the outputs an agent can rely on |
193
+ | [vscode-cobalto/](https://github.com/abstracta/cobalto/tree/v0.8.0/vscode-cobalto/) | The VS Code extension |
194
+ | [tests/](https://github.com/abstracta/cobalto/tree/v0.8.0/tests/) | Cobalto's own tests: `python3 tests/run.py` runs them all; its [README](https://github.com/abstracta/cobalto/blob/v0.8.0/tests/README.md) describes each layer |
195
+ | [.claude/skills/cobalto/](https://github.com/abstracta/cobalto/tree/v0.8.0/.claude/skills/cobalto/) | A Claude Code skill for writing and running Cobalto suites |
196
+ | [AGENTS.md](https://github.com/abstracta/cobalto/blob/v0.8.0/AGENTS.md) | Instructions for coding agents that work on Cobalto itself |
197
+ | [docs/logo/](https://github.com/abstracta/cobalto/tree/v0.8.0/docs/logo/) | Logo |
198
+
199
+ ## Contributing
200
+
201
+ The most useful contribution is running Cobalto on a compiler it has not been verified with and reporting what happened, whether it worked or not: [Adding a compiler](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/adding-a-compiler.md) explains how, and it needs no change to the code. For problems, fixes and everything else, see [CONTRIBUTING.md](https://github.com/abstracta/cobalto/blob/v0.8.0/CONTRIBUTING.md).
202
+
203
+ ## About the name
204
+
205
+ Cobalto is COBOL plus cobalt (*cobalto* in Spanish), element 27, a stable metal that resists heat and corrosion. **CBLT** is its technical abbreviation, used where standard COBOL needs short names: the `PROGRAM-ID`s of the library (`CBLTEQ`), the context copybook (`CBLTCTX`), the message codes (`CBLT-E200`), the suite extension (`.cblt`) and the CLI.
206
+
207
+ ## License
208
+
209
+ Apache-2.0. See [LICENSE](https://github.com/abstracta/cobalto/blob/v0.8.0/LICENSE). Cobalto borrows ideas from earlier COBOL unit testing projects, but includes no code from them: the parser, the rewriter, the COBOL library, the CLI and the extension were written from scratch.
@@ -0,0 +1,187 @@
1
+ <p align="center"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/abstracta/cobalto/v0.8.0/docs/logo/cobalto-logo-white.svg"><img src="https://raw.githubusercontent.com/abstracta/cobalto/v0.8.0/docs/logo/cobalto-logo.svg" alt="Cobalto" width="360"></picture></p>
2
+
3
+ # Cobalto
4
+
5
+ **Unit testing for COBOL that runs wherever your COBOL runs.**
6
+
7
+ Cobalto lets a team test, debug and understand its COBOL with the compiler it already has: no new licenses and no vendor lock-in. Tests are written in a small language that reads like COBOL and run from the command line or from VS Code, where a suite can also be debugged in COBOL terms, with the program's own statements and data names. Results come out in JUnit, LCOV, Cobertura XML and SonarQube's generic format, so they fit into an existing CI pipeline, and an AI model can propose a first draft of a suite for a person to review.
8
+
9
+ It is an open source project by [Abstracta](https://abstracta.us), created by Fabian Baptista and released under Apache-2.0.
10
+
11
+ ![Cobalto in VS Code: a failing test case, a debugging session that steps into the program down to the defect, the fix, and the suites passing with coverage](https://raw.githubusercontent.com/abstracta/cobalto/v0.8.0/vscode-cobalto/images/demo.gif)
12
+
13
+ ## Why
14
+
15
+ COBOL systems run critical processes in banks, insurers, government agencies and utilities, and the teams that maintain them change business logic with no tests to tell them when something breaks. The unit testing tools that exist for COBOL are tied to one compiler, one platform or one license, or are no longer maintained. For many teams the alternative is not another tool but no unit tests at all.
16
+
17
+ Cobalto gives a program a suite that does not depend on where it is compiled: the part that runs inside the COBOL is standard COBOL 85, and everything specific to an environment lives in a profile. GnuCOBOL shows the value of this on a single machine: the same suite compiled with the IBM or the Micro Focus dialect catches behavior that changes with the compiler, such as rounding, binary field sizes and truncation.
18
+
19
+ Cobalto is not a migration tool: it does not translate, convert or move code. A migration is one of the changes a suite makes safer, along with everyday maintenance, refactoring and a change of compiler or dialect. It is also the one where a portable suite pays off most, because the same tests run before and after.
20
+
21
+ ## How it works
22
+
23
+ - **Portable core.** The assertions, the test context and the driver that runs the suites are plain COBOL 85, fixed format, with no extensions.
24
+ - **One profile per environment.** How to compile, link and run, where the results file goes, and whether the build happens on another machine over ssh, all live in a declarative profile. Adding a compiler means writing a profile, not touching the core.
25
+ - **A CLI with no dependencies.** Python 3, standard library only. It discovers the suites, generates the test COBOL, compiles, runs, reads the results and writes the console output and the reports. It works on any machine with Python, with or without internet access.
26
+ - **A VS Code extension.** Test Explorer, coverage in the gutter and debugging in COBOL terms (breakpoints in the suite, stepping by statement, conditions written in COBOL, changing values) on top of the same project and the same CLI.
27
+
28
+ ## What you can test
29
+
30
+ **Whole programs.** A suite describes test cases that call the program under test through its interface (`CALL ... USING`) and check the results with readable assertions:
31
+
32
+ ```cobol
33
+ TESTSUITE TSTDISC 'Discounts by amount'
34
+
35
+ WORKING-STORAGE SECTION.
36
+ 01 WS-AMOUNT PIC 9(7)V99.
37
+ 01 WS-RESULT PIC 9(7)V99.
38
+ 01 WS-CATEGORY PIC X(10).
39
+
40
+ TESTCASE 'premium amount gets 20%'
41
+ MOVE 2000 TO WS-AMOUNT
42
+ CALL "DISCOUNT" USING WS-AMOUNT WS-RESULT WS-CATEGORY
43
+ EXPECT WS-RESULT TO BE NUMERIC 1600
44
+ EXPECT WS-CATEGORY TO BE 'PREMIUM'
45
+ ```
46
+
47
+ **Single paragraphs of a program, without refactoring it.** With in-program mode, Cobalto injects the suite into a copy of the program. Test cases can `PERFORM` any paragraph, read and set any `WORKING-STORAGE` field, and replace, one test case at a time, calls to other programs, file access, embedded SQL and the system date. `RUN` executes the original flow from its entry point, with the program's `STOP RUN` ending the test case instead of the process:
48
+
49
+ ```cobol
50
+ TESTSUITE TSTINV 'Invoicing (in-program on INVOICE)'
51
+ PROGRAM INVOICE
52
+
53
+ TESTCASE 'full process with mocked files'
54
+ MOCK FILE CUST-FILE
55
+ ON READ
56
+ EVALUATE CBLT-READ-COUNT
57
+ WHEN 1
58
+ MOVE "C001ACME 000200000" TO CUST-REC
59
+ WHEN OTHER
60
+ SET CBLT-AT-END TO TRUE
61
+ END-EVALUATE
62
+ END-MOCK
63
+ PERFORM 2000-PROCESS
64
+ EXPECT WS-TOTAL TO BE NUMERIC 1600
65
+ VERIFY CALL 'DISCOUNT' HAPPENED ONCE
66
+ VERIFY PARAGRAPH 3000-END NEVER HAPPENED
67
+ ```
68
+
69
+ A mock applies only to the test case that declares it. Every other test case runs the original code.
70
+
71
+ **Interface and internal cases.** The report marks each test case as an *interface* case, which only looks at what goes into the program and what comes out, or an *internal* case, which runs a paragraph or looks at the program's own fields. Interface cases are the ones that still make sense after the program is rewritten or translated.
72
+
73
+ **Coverage with any compiler.** With `--coverage`, the CLI instruments a copy of each program under test and measures statements, the branches of `IF`, `EVALUATE` and `SEARCH`, compound conditions by operand, and paragraphs, without gcov or a special runtime. The result goes to the console and to LCOV, Cobertura XML and SonarQube's generic format.
74
+
75
+ **Results as data.** `cobalto test --json` writes the whole run as JSON: totals, every test case, the expected and actual value of each assert and, with `--coverage`, coverage. The same model is saved to `build/results.json`, so a script never has to read console text. [Using Cobalto from a coding agent](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/coding-agents.md) covers the Claude Code skill, the loop it follows and which of these outputs an agent can rely on.
76
+
77
+ **A draft suite proposed by AI.** `cobalto suggest` asks a model for a suite for a program, compiles it, runs it with coverage and feeds back what failed or was left uncovered, in rounds. The result is a draft of characterization tests for a person to review, and everything sent to the provider is kept in `build/ai/`.
78
+
79
+ ## Status
80
+
81
+ What exists today, and how far each part has been verified:
82
+
83
+ | Capability | Verification |
84
+ |---|---|
85
+ | COBOL 85 core (assertions, context, driver) | `cobc -fsyntax-only` with no errors or warnings in the eight strict dialects of GnuCOBOL. Compiled, linked and run with VSI COBOL on OpenVMS |
86
+ | External and in-program suites, with mocks per test case (paragraphs, `CALL`, files, `EXEC SQL`, clock) | GnuCOBOL 3.2 on the seven example programs: 105 test cases, 415 asserts, 2 intentional failures, 6 skipped. 46 interface cases and 58 internal ones; the one test written in plain COBOL, without the DSL, is not classified. The SQL mock is not verified with a real precompiler |
87
+ | Portable coverage by statement, branch, condition and paragraph | GnuCOBOL 3.2. The Sonar report was checked with SonarQube Community; Sonar's COBOL analyzer (Enterprise edition) was not tried |
88
+ | The same suite across dialects: profiles `gnucobol-ibm` and `gnucobol-mf` | With `-std=ibm` five more test cases fail and with `-std=mf` two more, because of rounding and the size and truncation of binary fields |
89
+ | VS Code extension | macOS with GnuCOBOL 3.2, lldb-dap from Xcode and VS Code 1.147. On Linux, the debug adapter was verified over the protocol in a container |
90
+ | AI-assisted drafts (`cobalto suggest`) | Claude on three of the example programs: 36 test cases proposed in two rounds, all passing |
91
+ | Remote profiles (build and run on another machine) | The ssh mechanics are verified with a local simulator, where two test cases that use an indexed file still fail. For hosts without ssh, `cobalto report` reads a results file and a screen capture brought back by hand |
92
+
93
+ | Compiler | Status |
94
+ |---|---|
95
+ | GnuCOBOL 3.x on Linux and macOS | Verified |
96
+ | VSI COBOL V3.1-0007 on OpenVMS V8.4-2L3 | Verified with the generated DCL scripts run by hand and the results read by `cobalto report`. The generated build script was edited after that run (its labels were renamed) and has not been run on OpenVMS again. Automation over ssh is not verified |
97
+ | Micro Focus | Profile template only. Not verified |
98
+ | IBM Enterprise COBOL | No profile yet. Not verified |
99
+
100
+ Running on any compiler that follows the standard is the design goal. The table above is what has been checked.
101
+
102
+ ## Roadmap
103
+
104
+ The first release is 0.8.0, on PyPI, and every release is listed in the [changelog](https://github.com/abstracta/cobalto/blob/v0.8.0/CHANGELOG.md). Until 1.0, the CLI, the suite language and the file formats can still change. This is what is missing to get there:
105
+
106
+ | Area | Today | Needed for 1.0 |
107
+ |---|---|---|
108
+ | Compilers | GnuCOBOL and VSI COBOL verified | Micro Focus and IBM Enterprise COBOL verified with a real run |
109
+ | Remote builds | The ssh mechanics run against a local simulator | A build and a run over ssh on a real host |
110
+ | SQL mock | Covered by Cobalto's own tests, never run through a precompiler | Verified with a real precompiler |
111
+ | Free-format sources | Parsed; in-program mode not verified with a compiler | In-program mode verified on a free-format program |
112
+ | VS Code extension | On the Marketplace and Open VSX. Verified on macOS; on Linux, only the debug adapter | Verified end to end on Linux |
113
+ | Windows | Not tried | Verified, or documented as not supported |
114
+ | Stability | Interfaces can change between minor versions, and every change is listed in the changelog | The CLI, the suite language and the results format frozen and versioned |
115
+
116
+ The compiler rows are the ones where outside help counts most: see [Adding a compiler](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/adding-a-compiler.md).
117
+
118
+ ## Try it
119
+
120
+ You need Python 3.9 or later and GnuCOBOL 3.x (`brew install gnucobol` on macOS, the `gnucobol3` package on Debian and Ubuntu). Install the CLI from PyPI, in a virtual environment; it adds the `cobalto` command and its short alias `cblt`:
121
+
122
+ ```bash
123
+ python3 -m venv .venv
124
+ source .venv/bin/activate
125
+ python3 -m pip install cobalto
126
+ ```
127
+
128
+ The virtual environment keeps the install out of the system Python, which Homebrew and recent Debian and Ubuntu do not let `pip` modify. The command is available while the environment is active.
129
+
130
+ The example project is in this repository. Clone it and run its suites:
131
+
132
+ ```bash
133
+ git clone https://github.com/abstracta/cobalto.git
134
+ cd cobalto/examples
135
+ ```
136
+
137
+ ```bash
138
+ cobalto test --coverage
139
+ ```
140
+
141
+ ```bash
142
+ cobalto test --profile gnucobol-ibm
143
+ ```
144
+
145
+ ```bash
146
+ cobalto test --json
147
+ ```
148
+
149
+ The example project includes two test cases that fail on purpose, so these commands end with exit code 1.
150
+
151
+ To start a project of your own:
152
+
153
+ ```bash
154
+ cobalto init /path/to/my/project
155
+ ```
156
+
157
+ To install from a clone instead, for example to try a change that is not released yet, run `python3 -m pip install .` from the root of the clone, in a virtual environment.
158
+
159
+ To write a first suite step by step, see [First suite in 15 minutes](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/reference.md#first-suite-in-15-minutes) in the reference. The VS Code extension is `abstracta.vscode-cobalto`, on the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=abstracta.vscode-cobalto) and on [Open VSX](https://open-vsx.org/extension/abstracta/vscode-cobalto); see [its README](https://github.com/abstracta/cobalto/blob/v0.8.0/vscode-cobalto/README.md).
160
+
161
+ ## Where things are
162
+
163
+ | Path | What it is |
164
+ |---|---|
165
+ | [src/cobalto/](https://github.com/abstracta/cobalto/tree/v0.8.0/src/cobalto/) | The tool, as a Python package: the CLI, the COBOL core (`lib/`) and the built-in profiles (`profiles/`) |
166
+ | [examples/](https://github.com/abstracta/cobalto/tree/v0.8.0/examples/) | The example project: seven programs (`src/`), their suites (`tests/`) and its `cblt.json` |
167
+ | [docs/reference.md](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/reference.md) | The reference for the DSL, the project file, profiles, coverage, debugging and AI-assisted drafts |
168
+ | [docs/design.md](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/design.md) | How Cobalto is built and why: the portable core, the results protocol, in-program mode, coverage, and the limits of each |
169
+ | [docs/adding-a-compiler.md](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/adding-a-compiler.md) | How to try Cobalto with another compiler and contribute its profile |
170
+ | [docs/coding-agents.md](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/coding-agents.md) | Using Cobalto from a coding agent: the Claude Code skill, its loop and the outputs an agent can rely on |
171
+ | [vscode-cobalto/](https://github.com/abstracta/cobalto/tree/v0.8.0/vscode-cobalto/) | The VS Code extension |
172
+ | [tests/](https://github.com/abstracta/cobalto/tree/v0.8.0/tests/) | Cobalto's own tests: `python3 tests/run.py` runs them all; its [README](https://github.com/abstracta/cobalto/blob/v0.8.0/tests/README.md) describes each layer |
173
+ | [.claude/skills/cobalto/](https://github.com/abstracta/cobalto/tree/v0.8.0/.claude/skills/cobalto/) | A Claude Code skill for writing and running Cobalto suites |
174
+ | [AGENTS.md](https://github.com/abstracta/cobalto/blob/v0.8.0/AGENTS.md) | Instructions for coding agents that work on Cobalto itself |
175
+ | [docs/logo/](https://github.com/abstracta/cobalto/tree/v0.8.0/docs/logo/) | Logo |
176
+
177
+ ## Contributing
178
+
179
+ The most useful contribution is running Cobalto on a compiler it has not been verified with and reporting what happened, whether it worked or not: [Adding a compiler](https://github.com/abstracta/cobalto/blob/v0.8.0/docs/adding-a-compiler.md) explains how, and it needs no change to the code. For problems, fixes and everything else, see [CONTRIBUTING.md](https://github.com/abstracta/cobalto/blob/v0.8.0/CONTRIBUTING.md).
180
+
181
+ ## About the name
182
+
183
+ Cobalto is COBOL plus cobalt (*cobalto* in Spanish), element 27, a stable metal that resists heat and corrosion. **CBLT** is its technical abbreviation, used where standard COBOL needs short names: the `PROGRAM-ID`s of the library (`CBLTEQ`), the context copybook (`CBLTCTX`), the message codes (`CBLT-E200`), the suite extension (`.cblt`) and the CLI.
184
+
185
+ ## License
186
+
187
+ Apache-2.0. See [LICENSE](https://github.com/abstracta/cobalto/blob/v0.8.0/LICENSE). Cobalto borrows ideas from earlier COBOL unit testing projects, but includes no code from them: the parser, the rewriter, the COBOL library, the CLI and the extension were written from scratch.
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cobalto"
7
+ dynamic = ["version"]
8
+ description = "Portable unit testing for COBOL"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Fabian Baptista" }, { name = "Abstracta" }]
14
+ keywords = ["cobol", "unit-testing", "testing", "legacy", "gnucobol", "openvms"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Environment :: Console",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Topic :: Software Development :: Testing",
21
+ "Topic :: Software Development :: Testing :: Unit",
22
+ ]
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/abstracta/cobalto"
26
+ Documentation = "https://github.com/abstracta/cobalto/blob/main/docs/reference.md"
27
+ Issues = "https://github.com/abstracta/cobalto/issues"
28
+ Changelog = "https://github.com/abstracta/cobalto/blob/main/CHANGELOG.md"
29
+
30
+ # One program, two names: cobalto, and cblt for short.
31
+ [project.scripts]
32
+ cobalto = "cobalto.cli:main"
33
+ cblt = "cobalto.cli:main"
34
+
35
+ [tool.setuptools.packages.find]
36
+ where = ["src"]
37
+
38
+ # The COBOL core and the built-in profiles travel inside the package.
39
+ [tool.setuptools.package-data]
40
+ cobalto = ["lib/*", "profiles/*"]
41
+
42
+ [tool.setuptools.dynamic]
43
+ version = { attr = "cobalto.__version__" }