Skip to content

Use OS-created directories for Clang AST tests #249

Description

@lm-sousa

Problem

AClangAstTester builds a per-instance directory name as:

temp-clang-ast-<System.nanoTime()>-<Thread.currentThread().getId()>

This was introduced in 5a9815e688311dfc6abee7ab2f89355be7246581 to stop parallel test instances from sharing copied resources, outputFirst, outputSecond, and cleanup targets.

The isolation requirement is valid, but timestamp plus Java thread ID is a hand-rolled uniqueness scheme. It does not provide the operating system's atomic directory allocation and is weaker across concurrent JVMs or overlapping Gradle runs.

Proposed change

Create one OS-allocated temporary directory per AClangAstTester instance, for example with Files.createTempDirectory("temp-clang-ast-"), and retain that path for the full test lifecycle.

Use that directory for:

  • copied input resources;
  • the first generated output;
  • the second parse/output pass;
  • instance-scoped cleanup.

Acceptance criteria

  • Two test instances running concurrently never share an input or output directory.
  • Separate JVMs and overlapping Gradle invocations receive distinct directories.
  • Cleanup deletes only the directory allocated to that test instance.
  • Debug or keep-files behavior remains explicit and does not contaminate a later test.
  • The test does not depend on the repository working directory.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions