The same solution works via UI but fails tests when uploaded via exercism CLI

Hi,

Here is my solution for Acronym in Bash on Exercism

#!/usr/bin/env bash

function acronym() {
  local acronym=""

  phrase="${1//[^a-zA-Z\']/ }"
  for word in $phrase; do
    acronym+="${word:0:1}"
  done

  echo "${acronym^^}"
}

acronym "$@"

Bash version on my local:
GNU bash, version 5.2.15(1)-release (aarch64-apple-darwin21.6.0)

The exact same solution works against all tests when I submit it via the online editor on Exercism portal.

But, all tests fail (empty output against all tests) when submitted via the exercism CLI:
exercism submit acronym.sh

Could you kindly help look into this?
Thanks.

Hello. The reason it fails is that the correct filename is acronym.sh but you have submitted a file called acronym-bash.sh via the CLI.

So I suspect that either:

  • You ran exercism submit acronym-bash.sh
  • You ran exercism submit acronym* (or similar)
  • You ran exercism submit and there is a bug

Could you try ensuring that the only file in your directory is acronym.sh and run exercism submit acronym.sh pls? If that works, then we can try and work out which of the above was the root problem. Thanks.

(CC @glennj on the off-chance this is a bash thing and @ErikSchierboom from a CLI perspective)

(You can also step through the iterations at anjali-sharma's solution for Acronym in Bash on Exercism and see the tabs at the top to demonstrate what I mean)

you’re right. I used a different filename for the new iteration. I assumed exercism submit acronym-bash.sh should work as expected.

Submitting with the expected filename works.
thanks a lot!

The filename acronym.sh is hardcoded in the test script.

I think the confusion occurred because running the test suite locally across any file path works as expected. Might be nice to include it as help text.

I don’t understand what that means. What is “any file path”?

If you had locally both acronym.sh (which passed the tests) and acronym-bash.sh (which failed), then if you submitted only acronym-bash.sh, then the remote test runner would fail.

As Glenn said, the filename acronym.sh is hard coded into the test script. See, for instance, this line. run bash acronym.sh 'Portable Network Graphics'. It does not work with other filenames.

Yeah, got it. I had both acronym.sh and acronym-bash.sh as two approaches to the problem and both passed against the tests locally. I missed the hardcoded filename when submitting the solution. Thanks for the support everyone.

1 Like