Skip to content

Commit

Permalink
refactor: grammar, typechecking, end-to-end, CLI tests (#402)
Browse files Browse the repository at this point in the history
Most grammar and typechecking test files have been renamed to convey their meaning,
some duplicate or useless tests were removed. Reduced some boiler-plate in end-to-end tests.
  • Loading branch information
anton-trunov authored Jun 12, 2024
1 parent f51821d commit 63f7065
Show file tree
Hide file tree
Showing 292 changed files with 7,140 additions and 7,023 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ node_modules/
dist/
coverage/
**/output/
./src/test/bugs/output/
./src/test/features/output/
src/test/**/output/
src/func/funcfiftlib.js
src/grammar/grammar.ohm*.ts
src/grammar/grammar.ohm*.js
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/tact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,26 @@ jobs:
- name: CLI Test | Check single-contract compilation
run: |
tact --check test/tact-cli/success.tact
tact --func test/tact-cli/success.tact
tact test/tact-cli/success.tact
tact --check bin/test/success.tact
tact --func bin/test/success.tact
tact bin/test/success.tact
- name: CLI Test | Check compilation via `--config`
run: |
# should output complete results
tact --config test/tact-cli/success.config.json
tact --config bin/test/success.config.json
# should only run the syntax and type checking
tact --config test/tact-cli/success.config.json --check
tact --config bin/test/success.config.json --check
- name: CLI Test | Check parsing of a non-existing CLI flag
if: runner.os != 'Windows'
run: |
! tact --nonexistentoption test/tact-cli/success.config.json
! tact --nonexistentoption bin/test/success.config.json
- name: CLI Test | tact executable return non-zero exit code if compilation fails
if: runner.os != 'Windows'
run: |
! tact --config test/tact-cli/fail.config.json
! tact --config bin/test/fail.config.json
- name: Link Tact compiler
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Trailing semicolons in struct and message declarations are optional now: PR [#395](https://github.com/tact-lang/tact/pull/395)
- Tests are refactored and renamed to convey the sense of what is being tested and to reduce the amount of merge conflicts during development: PR [#402](https://github.com/tact-lang/tact/pull/402)

### Fixed

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 18 additions & 12 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"language": "en",
"words": [
"alnum",
"assgn",
"augmentedassign",
"blockstore",
"bounceable",
Expand All @@ -16,7 +17,9 @@
"dnsresolve",
"Fift",
"forall",
"funs",
"funcfiftlib",
"initof",
"ipfs",
"ipld",
"jettons",
Expand Down Expand Up @@ -48,11 +51,13 @@
"stdlib",
"struct",
"structs",
"subtyping",
"testdata",
"Topup",
"typechecker",
"uintptr",
"uncons",
"uninit",
"unixfs",
"workchain",
"привет",
Expand All @@ -72,18 +77,19 @@
"src/generator/writers/__snapshots__/writeSerialization.spec.ts.snap",
"src/grammar/grammar.ohm-bundle.d.ts",
"src/imports/stdlib.ts",
"src/test/__snapshots__/bugs.spec.ts.snap",
"src/test/__snapshots__/feature-constants.spec.ts.snap",
"src/test/__snapshots__/feature-deep.spec.ts.snap",
"src/test/__snapshots__/feature-implicit-init.spec.ts.snap",
"src/test/__snapshots__/feature-masterchain.spec.ts.snap",
"src/test/__snapshots__/feature-try-catch.spec.ts.snap",
"src/test/feature-address.spec.ts",
"src/test/feature-intrinsics.spec.ts",
"src/test/feature-optionals.spec.ts",
"src/test/feature-strings.spec.ts",
"src/test/features/intrinsics.tact",
"src/test/features/strings.tact",
"/src/test/compilation-failed/const-eval-failed.spec.ts",
"src/test/e2e-emulated/__snapshots__/constants.spec.ts.snap",
"src/test/e2e-emulated/__snapshots__/deep.spec.ts.snap",
"src/test/e2e-emulated/__snapshots__/implicit-init.spec.ts.snap",
"src/test/e2e-emulated/__snapshots__/masterchain.spec.ts.snap",
"src/test/e2e-emulated/__snapshots__/sample-jetton.spec.ts.snap",
"src/test/e2e-emulated/__snapshots__/try-catch.spec.ts.snap",
"src/test/e2e-emulated/address.spec.ts",
"src/test/e2e-emulated/intrinsics.spec.ts",
"src/test/e2e-emulated/optionals.spec.ts",
"src/test/e2e-emulated/strings.spec.ts",
"src/test/e2e-emulated/contracts/intrinsics.tact",
"src/test/e2e-emulated/contracts/strings.tact",
"src/test/compilation-fail/fail-const-eval.spec.ts",
"stdlib/stdlib.fc"
]
Expand Down
11 changes: 9 additions & 2 deletions jest.teardown.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ module.exports = async () => {
__dirname,
"src",
"test",
"features",
"codegen",
"output",
"*.boc",
),
path.resolve(
__dirname,
"src",
"test",
"e2e-emulated",
"output",
"*.boc",
),
path.resolve(__dirname, "src", "test", "bugs", "output", "*.boc"),
path.resolve(
__dirname,
"src",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"dist/**/*",
"src/**/*",
"bin/**/*",
"stdlib/**/*"
"stdlib/**/*",
"!**/test"
],
"main": "./dist/main.js",
"bin": {
Expand Down
28 changes: 0 additions & 28 deletions scripts/prepare.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import fs from "fs";
import { decompileAll } from "@tact-lang/opcode";
import { run } from "../src/node";
import { build } from "../src/pipeline/build";
import { FuncCompilationResult, funcCompile } from "../src/func/funcCompile";
import path from "path";
import { ConfigProject } from "../src/config/parseConfig";
import { createNodeFileSystem } from "../src/vfs/createNodeFileSystem";
import { glob } from "glob";
import { verify } from "../src/verify";
import { consoleLogger } from "../src/logger";
Expand Down Expand Up @@ -35,31 +32,6 @@ import { __DANGER__disableVersionNumber } from "../src/pipeline/version";
}
}

// Compile test contracts
for (const p of [
{ path: path.resolve(__dirname, "..", "src", "test", "contracts") },
]) {
const recs = fs.readdirSync(p.path);
for (const r of recs) {
if (!r.endsWith(".tact")) {
continue;
}

const config: ConfigProject = {
name: r.slice(0, r.length - ".tact".length),
path: "./" + r,
output: "./output/",
};
const stdlib = "@stdlib";
const project = createNodeFileSystem(p.path, false);
await build({
config,
stdlib,
project,
});
}
}

// Compile func files
for (const p of [{ path: __dirname + "/../func/" }]) {
const recs = fs.readdirSync(p.path);
Expand Down
Loading

0 comments on commit 63f7065

Please sign in to comment.