Syntax highlight for Stdout and Stderr - shell

I'm developing an application that runs some shell commands, and I want to print the shell output in my web app in a pretty way. I tried some syntax highlighters, but it doesn't recognize the colors or break lines for example.
Here is an output example:
FAIL tmp/jest_client/0052ba7f-1c68-4f16-924f-5d44fa0ea415.test.js (5.511s)↵ some↵ ✕ returns 2 (3ms)↵↵ ● some › returns 2↵↵ ReferenceError: some is not defined↵ ↵ at Object.<anonymous> (tmp/jest_client/0052ba7f-1c68-4f16-924f-5d44fa0ea415.test.js:5:11)↵↵Test Suites: 1 failed, 1 total↵Tests: 1 failed, 1 total↵Snapshots: 0 total↵Time: 13.869s↵Ran all test suites matching /tmp/jest_client/0052ba7f-1c68-4f16-924f-5d44fa0ea415.test.js/i.↵
Thaks for your help!

To solve this problem, I used the aha Linux package.

Related

How to generate flamegraphs from macOS process samples?

Anyone have a clean process for converting samples on macOS to FlameGraphs?
After a bit of fiddling I thought I could perhaps use a tool such as flamegraph-sample, but it seems to give me some trouble and so I thought perhaps there may be other more up-to-date options that I'm missing insomuch that this tool gives an error:
$ sudo sample PID -file ~/tmp/sample.txt -fullPaths 1
Sampling process 198 for 1 second with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Sample analysis of process 35264 written to file ~/tmp/sample.txt
$ python stackcollapse-sample.py ~/tmp/sample.txt > ~/tmp/sample_collapsed.txt
$ flamegraph.pl ~/tmp/sample_collapsed.txt > ~/tmp/sample_collapsed_flamegraph.svg
Ignored 2335 lines with invalid format
ERROR: No stack counts found

What is pylint exit code 28?

Pylint exited with code 28 on Linux run. What does this error code mean?
I know it doesn't mean low on space as I tried the same command on a empty VM.
Answer + Examples:
(Note the pylint exit codes table below from pylint official site.
pylint exit codes conforms to 2 to the power of x (x = 0 to 5)
This is a crystal clear sign that they use a binary system for exit codes, this means that (as mentioned in the example within the image below) if exit code is:
28 - in binary: 0001 1100 (exit code 4, 8, 16 was triggered at least once for each)
63 - in binary: 0011 1111 (all error codes was triggered at least once for each which is the maximum errors combined)
Pyline exit code 28 on Linux and exit code 30 on Windows both mean that the config file that you are feeding in has an invalid configuration.
For me that was having underscores separating words instead of dashes. I had changed this because the wheel build deprecated dashes for flake8 and mypy but pylint needs to remain with dashes separating the words.

H-PoPG Haplotyper NullPointerException Error at algorithms.HBOP2Builder

Hello I am building a genome assembly method and a critical step of my pipeline is phasing. I've been searching through different methods and recently discovered H-PoPG which looks promising for polyploid haplotyping. I am trying to test my data on it but I got the following result and couldn't find any help or forum on the web.
This is the command I am using:
java -jar H-PoPG.jar -p 3 -w 0.9 -f fragment_matrix_Chrm1 -vcf PilonChrm1.vcf -o output_phased_Chrm1
This is the error message:
Exception in thread "main" java.lang.NullPointerException
at algorithms.HBOP2Builder.<init>(HBOP2Builder.java:59)
at algorithms.HBOP2Builder.<init>(HBOP2Builder.java:25)
at algorithms.HPBOP2Alg.buildHaplotype(HPBOP2Alg.java:24)
at main.PolyPlotyping.Polyphasing(PolyPlotyping.java:224)
at main.PolyPlotyping.go(PolyPlotyping.java:159)
at main.PolyPlotyping.main(PolyPlotyping.java:280)
srun: error: neumann: task 0: Exited with exit code 1
Could anyone point me in the right direction by explaining me where this error could come from?
Many Thanks
I have run your data and found it is OK to run the command without the vcf file.
The error messages occur when it is run with the vcf file.
The vcf file contains many overlaps such as:
Chromosome_1_Reference 16 . A . 1486 LowCov DP=39;TD=43;BQ=38;MQ=57;QD=38;BC=39,0,0,0;QP=100,0,0,0;PC=119;IC=0;DC=0;XC=0;AC=0;AF=0.00 GT 0/0
Chromosome_1_Reference 16 . AAACCC A . Amb;LowCov DP=56;TD=60;BQ=39;MQ=57;QD=25;BC=19,21,0,0;QP=48,52,0,0;PC=119;IC=0;DC=16;XC=1;AC=1;AF=0.29 GT 0/1
Chromosome_1_Reference 17 . A C 1018 Amb;LowCov DP=56;TD=60;BQ=39;MQ=57;QD=25;BC=19,21,0,0;QP=48,52,0,0;PC=119;IC=0;DC=16;XC=1;AC=1;AF=0.52 GT 0/1
Please check the vcf file and ensure that every SNP position is covered by only one line,
and that the last column of each line should be 0/0/1 or 0/1/1 when the polyploidy is 3 (-p 3).

Checking output from "command" should contain unexpected crash with NilClass

In an effort to use Cucumber for a command-line script, I've installed the aruba gem as per the instructions provided. It's in my Gemfile, I can verify that the correct version is installed and I've included
require 'aruba/cucumber'
in 'features/env.rb'
In order to ensure it works, I wrote the following scenario:
#announce
Scenario: Testing cucumber/aruba
Given a blank slate
Then the output from "ls -la" should contain "drw"
assuming the thing should fail.
It does fail, but it fails for the wrong reasons:
#announce
Scenario: Testing cucumber/aruba
Given a blank slate
Then the output from "ls -la" should contain "drw"
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[] (NoMethodError)
features/dataloader.feature:9:in `Then the output from "ls -la" should contain "drw"'
Anyone have any ideas why this isn't working? This seems to be very basic aruba behavior.
You are missing a 'When' step - the aruba "output should contain" step requires the command to have already run (it does not run it itself, it only looks it up).
#announce
Scenario: Testing cucumber/aruba
Given a blank slate
When I run `ls -la`
Then the output from "ls -la" should contain "drw"
This produces, on my machine:
#announce
Scenario: Testing cucumber/aruba # features/test_aruba.feature:8
When I run `ls -la` # aruba-0.4.11/lib/aruba/cucumber.rb:56
$ cd /Users/d.chetlin/dev/mine/ladder/tmp/aruba
$ ls -la
total 0
drwx------ 2 d.chetlin staff 68 Feb 15 23:38 .
drwx------ 7 d.chetlin staff 238 Feb 15 23:38 ..
Then the output from "ls -la" should contain "drw" # aruba-0.4.11/lib/aruba/cucumber.rb:86
1 scenario (1 passed)
2 steps (2 passed)
0m0.465s

How to compare results of two RSpec suite runs?

I have a pretty big spec suite (watirspec), I am running it against a Ruby gem (safariwatir) and there are a lot of failures:
1002 examples, 655 failures, 1 pending
When I make a change in the gem and run the suite again, sometimes a lot of previously failing specs pass (52 in this example):
1002 examples, 603 failures, 1 pending
I would like to know which previously failing specs are now passing, and of course if any of the previously passing specs are now failing. What I do now to compare the results is to run the tests with --format documentation option and output the results to a text file, and then diff the files:
rspec --format documentation --out output.txt
Is there a better way? Comparing text files is not the easiest way to see what changed.
Just save the results to file like you're doing right now and then just diff those results with some random diff-ing tool.
I don't know of anything out there that can do exactly that. Said that, if you need it so badly you don't mind spending some time hacking your own formatter, take a look at Spec::Runner::Formatter::BaseFormatter.It is pretty well documented.
I've implemented #Serabe's solution for you. See the gist: https://gist.github.com/1142145.
Put the file my_formatter.rb into your spec folder and run rspec --formatter MyFormatter. The formatter will compare current run result with previous run result and will output the difference as a table.
NOTE: The formatter creates/overwrites file result.txt in the current folder.
Example usage:
D:\Projects\ZPersonal\equatable>rspec spec --format MyFormatter
..........
No changes since last run
Finished in 0.011 seconds
10 examples, 0 failures
No changes since last run line was added by the formatter.
And now I intentionally broken one and rerun rspec:
D:\Projects\ZPersonal\equatable>rspec spec --format MyFormatter
..F.......
Affected tests (1).
PS CS Description
. F Equatable#== should be equal to the similar sock
PS - Previous Status
CS - Current Status
Failures:
1) Equatable#== should be equal to the similar sock
Failure/Error: subject.should == Sock.new(10, :black, 0)
expected: #<Sock:0x2fbb930 #size=10, #color=:black, #price=0>
got: #<Sock:0x2fbbae0 #size=10, #color=:black, #price=20> (using ==)
Diff:
## -1,2 +1,2 ##
-#<Sock:0x2fbb930 #color=:black, #price=0, #size=10>
+#<Sock:0x2fbbae0 #color=:black, #price=20, #size=10>
# ./spec/equatable_spec.rb:30:in `block (3 levels) in <top (required)>'
Finished in 0.008 seconds
10 examples, 1 failure
Failed examples:
rspec ./spec/equatable_spec.rb:29 # Equatable#== should be equal to the similar sock
The table with affected specs was added by the formatter:
Affected tests (1).
PS CS Description
. F Equatable#== should be equal to the similar sock
PS - Previous Status
CS - Current Status
If some spec status is different between current and previous run, the formatter outputs previous status, current status and spec description. '.' stands for passed specs, 'F' for failed and 'P' for pending.
The code is far from perfect, so feel free to criticize and change it as you want.
Hope this helps. Let me know if you have any questions.

Resources