Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions src/frontend/gg-describe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <unistd.h>
#include <cstring>
#include <iostream>
#include <fstream>
#include <getopt.h>
#include <glob.h>

Expand Down Expand Up @@ -67,7 +68,10 @@ int main( int argc, char * argv[] )
return EXIT_FAILURE;
}

roost::path thunk_path { argv[ optind ] };
std::string query = argv[ optind ];

roost::path thunk_path { query };
cerr << thunk_path.string() << endl;

if ( not roost::exists( thunk_path ) ) {
thunk_path = gg::paths::blob( argv[ optind ] );
Expand All @@ -93,18 +97,23 @@ int main( int argc, char * argv[] )
}
}

Thunk thunk = ThunkReader::read( thunk_path );
if ( query[0] == 'V' ) {
ifstream value( thunk_path.string() );
cout << value.rdbuf();
} else {
Thunk thunk = ThunkReader::read( thunk_path );

if ( print_executable_hash ) {
cout << thunk.executable_hash() << endl;
}
if ( print_executable_hash ) {
cout << thunk.executable_hash() << endl;
}

if ( print_command ) {
cout << command_str( thunk.function().args(), thunk.function().envars() ) << endl;
}
if ( print_command ) {
cout << command_str( thunk.function().args(), thunk.function().envars() ) << endl;
}

if ( not print_executable_hash and not print_command ) {
cout << protoutil::to_json( thunk.to_protobuf(), true ) << endl;
if ( not print_executable_hash and not print_command ) {
cout << protoutil::to_json( thunk.to_protobuf(), true ) << endl;
}
}
}
catch ( const exception & e ) {
Expand Down
3 changes: 2 additions & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ dist_check_SCRIPTS = fetch-vectors.test \
model-ar.test model-ranlib.test model-strip.test \
model-ld.test gnu-hello.test mosh.test \
mosh-fewer-thunks.test fibonacci.test \
sdk.test cleanup.test
sdk.test cleanup.test \
describe-value.test

thunk_roundtrip_SOURCES = thunk-roundtrip.cc
sandbox_test_SOURCES = sandbox-test.cc
Expand Down
20 changes: 20 additions & 0 deletions tests/describe-value.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash -xe

cd ${TEST_TMPDIR}

export PATH=${abs_builddir}/../src/models:${abs_builddir}/../src/frontend:$PATH

gg-init

echo Hi > a.txt

gg-collect a.txt

hash=$(gg-hash a.txt)

for i in $(seq 1 "${#hash}"); do

diff a.txt <(gg-describe $(echo $hash | cut "-c1-${i}"))

done