Permission Denied for Rails system test

I’m adding parallelism by adding 2 containers and splitting the test by timings data. Up until now, builds have been fine. But I am now getting a Permission Denied error for a specific Rails system test. I’m running a Rails 5.2 app and using minitest. Here is my circleci config:

version: 2
    working_directory: ~/my_app
    parallelism: 2

      - image: circleci/ruby:2.5-node-browsers
          RAILS_ENV: test
          BUNDLE_JOBS: 3
          BUNDLE_RETRY: 3
          BUNDLE_PATH: vendor/bundle
          PGUSER: test_user

      - image: circleci/postgres:10.4-alpine
          POSTGRES_USER: test_user
          POSTGRES_DB: my_app_test

      - image: circleci/redis:4

      - image: circleci/node:jessie-browsers

      - checkout

      # Download and cache dependencies
      - restore_cache:
          - v1-dependencies-{{ checksum "Gemfile.lock" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run:
          name: Install mcrypt library
          command: sudo apt-get install libmcrypt-dev

      - run:
          name: Bundle Install
          command: bundle check || bundle install

      - save_cache:
            - ./vendor/bundle
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}

      - run:
          name: Copy secret files
          command: |
            cp config/ config/database.yml
      # Database setup
      # Waits until DB service is available, according to CircleCI docs:
      - run:
          name: Wait for DB
          command: dockerize -wait tcp://localhost:5432 -timeout 1m

      - run:
          name: Database Setup
          command: |
            bundle exec rake db:create
            bundle exec rake db:schema:load  

      - run:
          name: Create directy to store test results
          command: mkdir test/reports

      - run:
          name: Download Selenium
          command: curl -O

      - run:
          name: Start Selenium
          command: java -jar selenium-server-standalone-3.5.3.jar -log test-reports/selenium.log
          background: true

      - run:
          name: Run Tests
          command: |
            bundle exec rake test
            bundle exec rake test:system TESTOPTS='--verbose'
            $(circleci tests glob "test/**/*_test.rb" | circleci tests split --split-by=timings)

      - store_test_results:
          path: test/reports

The error I’m getting is:

101 runs, 565 assertions, 0 failures, 0 errors, 2 skips
/bin/bash: line 2: test/system/dashboard_test.rb: Permission denied
Exited with code 126

There aren’t any permission issues when not configuring for parallelism and setting the test output results.
What am I doing wrong?

I wonder if the command needs to do ruby <test>.rb rather than just <test>.rb? If so, perhaps there is a mode for that in the circleci command.

Personally, if I were splitting tests I wouldn’t bother with the circleci command - most test systems give you a way to run tests by file, folder, annotation tag, etc - you can then use the parallelism env vars to see which set to run.

The output of the glob and test split should be file args to the bundle rake test command right?
If thats the case, try changing your script to the following, the rake command and the test split output suppose to be in one line.

      - run:
          name: Run Tests
          command: |
            bundle exec rake test
            bundle exec rake test:system TESTOPTS='--verbose' \ 
            $(circleci tests glob "test/**/*_test.rb" | circleci tests split --split-by=timings)